回答:
使用$ne- $not標準演算子が後に続きます:
$ne等しくないことを表すの例:
use test
switched to db test
db.test.insert({author : 'me', post: ""})
db.test.insert({author : 'you', post: "how to query"})
db.test.find({'post': {$ne : ""}})
{ "_id" : ObjectId("4f68b1a7768972d396fe2268"), "author" : "you", "post" : "how to query" }
そして今$not、述語($ne)を取り、それを否定($not)します:
db.test.find({'post': {$not: {$ne : ""}}})
{ "_id" : ObjectId("4f68b19c768972d396fe2267"), "author" : "me", "post" : "" }
$not :{ $ne手段 $eq、これはあなたが言うしようとしていた何ですか?
複数を実行したい場合$neは、
db.users.find({name : {$nin : ["mary", "dick", "jane"]}})
$ne代わりに使用$not
http://docs.mongodb.org/manual/reference/operator/ne/#op._S_ne
db.collections.find({"name": {$ne: ""}});
Mongo docsから:
$notオペレータは、他の事業者に影響を与え、独立してフィールドや文書を確認することができません。したがって、$not論理和に演算子を使用し、演算子を使用して$neフィールドの内容を直接テストします。
フィールドを直接テストしているので、$neここで使用する適切な演算子です。
編集:
使用したい状況$notは次のとおりです。
db.inventory.find( { price: { $not: { $gt: 1.99 } } } )
これにより、次のすべてのドキュメントが選択されます。
null配列にaがあり、それを避けたい場合:
db.test.find({"contain" : {$ne :[] }}).pretty()
$neために「等しくない」を指します。