Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is my document:

{ 
    title:"Happy thanksgiving",
    body: "come over for dinner",
    blocked:[
       {user:333, name:'john'},
       {user:994, name:'jessica'},
       {user:11, name: 'matt'},
    ]
}

What is the query to find all documents that do not have user 11 in "blocked"?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
828 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use $in or $nin for "not in"

Example ...

> db.people.find({ crowd : { $nin: ["cool"] }});

I put a bunch more examples here: http://learnmongo.com/posts/being-part-of-the-in-crowd/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...