I would like to request a subdocument in which the results should have all fields specified and others . Is it possible? And if so, how?
For instance:
I need a query like this:
db.users.find({
"pref.no_popup": true,
"pref.font_large": false,
"pref": { "$size", 2 }});
To fit this:
{
"user": "Ed",
"pref": {
"no_popup": true,
"font_large": false
}
}
But not this:
{
"user": "James",
"pref": {
"no_popup": true,
"font_large": false,
"font_red": true
}
}
I understand that the $ size operator is for arrays, so how can I do something similar for subdocuments?
Note that I tried not to use dot notation to request the exact presence of the field, but then I had problems with ordering.
source
share