답변:
사용 $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대신 사용$not
http://docs.mongodb.org/manual/reference/operator/ne/#op._S_ne
db.collections.find({"name": {$ne: ""}});
로부터 몽고 워드 프로세서 :
$not연산자는 다른 연산자에 영향을 미치는 독립적으로 필드 및 문서를 확인할 수 없습니다. 따라서$not논리적 분리 에는 연산자를 사용하고$ne필드의 내용을 직접 테스트하려면 연산자를 사용하십시오.
현장을 직접 테스트하고 $ne있으므로 여기서 사용하기에 적합한 연산자입니다.
편집하다:
사용하려는 상황은 다음과 같습니다 $not.
db.inventory.find( { price: { $not: { $gt: 1.99 } } } )
다음과 같은 모든 문서가 선택됩니다.
null배열에있는 경우 이를 피하려면 :
db.test.find({"contain" : {$ne :[] }}).pretty()
$ne은 "같지 않음"을 말합니다.