如何做一个“不输入”查询在Mongo? [英] How do I do a "NOT IN" query in Mongo?
本文介绍了如何做一个“不输入”查询在Mongo?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的文档:
{
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"?
推荐答案
您可以使用
You can use $in or $nin for "not in"
示例...
> db.people.find({ crowd : { $nin: ["cool"] }});
我把更多的例子放在这里: http://learnmongo.com/posts/being-part-of-the-in-crowd/
I put a bunch more examples here: http://learnmongo.com/posts/being-part-of-the-in-crowd/
这篇关于如何做一个“不输入”查询在Mongo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文