I have a MongoDB collection called references that has a document where I need to return all the objects that have a key called format with the value of 1. An example of the document looks like this:
{
"_id" : ObjectId("878f92ad6d9e8089aa3456a9"),
"categories" : {
"1" : {
"format" : 1,
...
}
}
}
I have tried this:
db.references.find({
"_id" : ObjectId("878f92ad6d9e8089aa3456a9"),
"categories.$.format" : 1
}).pretty();
As well as this:
db.references.find({
"_id" : ObjectId("878f92ad6d9e8089aa3456a9"),
"categories.*.format" : 1
}).pretty();
and both of those are returning nothing.