is it possible to create following schema with mongoose
{
"_id": ObjectId("542014e432315e917e7cc335"),
"displayName": "jimmy",
......
"stats": {
"2014-10": {
"documentsCount": NumberInt(1),
"usedStorage": NumberInt(100),
"usedBandwidth": NumberInt(250)
},
"2014-11": {
"documentsCount": NumberInt(1),
"usedStorage": NumberInt(500),
"usedBandwidth": NumberInt(150)
}
}
}
- How do declare the 'stats' fields in schema?
- Is it possible to find necessary subdocument in 'stats' by keyname and update it or insert new (if it doesn't exist)?