MongoDB不等于
我试图在MongoDB中显示一个文本字段不是''(空白)
{ 'name' : { $not : '' }}  但是我得到的错误invalid use of $not 
 我查看了文档,但他们使用的例子是复杂的情况(与正则expression式和$not否定另一个操作符)。 
我将如何做我想要做的简单的事情?
 使用$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" : "" } 
 如果你想做多个$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文档 :
$not操作符只影响其他操作符,不能单独检查字段和文档。 因此,使用$not运算符来进行逻辑分离,使用$ne运算符来直接testing字段的内容。
 既然你是直接testing字段$ne是在这里使用的正确的运算符。 
编辑:
 你想使用$not是: 
 db.inventory.find( { price: { $not: { $gt: 1.99 } } } ) 
这将select所有文件,其中:
- 价格字段值小于或等于1.99或价格
- 字段不存在
 如果数组中有一个null ,并且想要避免它: 
 db.test.find({"contain" : {$ne :[] }}).pretty() 
真实生活的例子; find所有但不是当前用户:
 var players = Players.find({ my_x: player.my_x, my_y: player.my_y, userId: {$ne: Meteor.userId()} });