Reputation: 272214
Let's say I have a collection of "rooms". Each room is a document that looks like this:
room = {
perms: [ { user:"matt", visible: 1 },
{ user:"alex", visible: 0 },
{ user:"jennifer", visible: 1 },
};
In MongoDB, how would I find rooms that have a permission of user=alex and visible=0
?
Upvotes: 1
Views: 124
Reputation: 860
If I understand your question correctly, the $elemMatch operator should do what you want:
{ "perms": { "$elemMatch": { "user": "alex", "visible": 0 } } }
Upvotes: 1