1

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 ?

1 Answer 1

1

If I understand your question correctly, the $elemMatch operator should do what you want:

{ "perms": { "$elemMatch": { "user": "alex", "visible": 0 } } }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.