i have a collection that is storing data in this format :
{
_id: ObjectId("51b9be6dbbdeef1e5f008cca"),
name: 'sfdsfsdfsdfsdfsd'
details: {
varA: {
created: "2013-06-13T12:43:25.853Z",
validity: "2013-07-13T12:43:25.853Z",
modified: "2013-06-13T12:43:25.853Z"
},
varB: {
created: "2013-06-13T12:43:25.853Z",
validity: "2013-07-13T12:43:25.853Z",
modified: "2013-06-13T12:43:25.853Z"
}
}
}
I would like to be able to expose only the varA data in this format (without the nested depth...) :
{
_id: ObjectId("51b9be6dbbdeef1e5f008cca"),
name: 'sfdsfsdfsdfsdfsd',
created: "2013-06-13T12:43:25.853Z",
validity: "2013-07-13T12:43:25.853Z",
modified: "2013-06-13T12:43:25.853Z"
}
Unfortunately, my query (wher i'm using projection) :
db.coll.find({}, {'details.varB': 0})
return something like this :
{
_id: ObjectId("51b9be6dbbdeef1e5f008cca"),
name: 'sfdsfsdfsdfsdfsd',
details: {
varA: {
created: "2013-06-13T12:43:25.853Z",
validity: "2013-07-13T12:43:25.853Z",
modified: "2013-06-13T12:43:25.853Z"
}
}
How can I improve the find query to return the expected format ?
Thanks a lot in advance for those who will help me ;-)
P.S. here i'm using the mongo shell to retrieve the data but i need to get this query working with node.js with node-mongodb-native.