Is there a way to return only the value of a property in a mongodb projection? For instance, I have a document that has a property whose value is an array. I want the return object from a query to be the array only, not property: [ .. ]
. Example:
Document:
db.test.insert({ name: "Andrew",
attributes: [ { title: "Happy"},
{ title: "Sad" }
]
});
Query:
db.test.find({name: "Andrew"},{attributes:1, "_id":0});
That returns:
{ "attributes" : [ { "title" : "Happy" }, { "title" : "Sad" } ] }
I want it to return on the array:
[ { title: "Happy"},
{ title: "Sad" }
]
Is there a way to do that? Thanks