본문 바로가기
MongoDB/Logical Query Operators

[MongoDB] $not

by 드름이 2022. 6. 30.

요약: 지정된 operator 표현식과 일치하지 않는 모든 document를 가져옵니다.

 

 


1.  inventory collection에서 "가격" 필드의 값이 1.99가 아닌 모든 document 를 선택합니다.

("가격" 필드가 없는 document 포함)

db.inventory.find( { 가격: { $not: { $gt: 1.99 } } } )

 

$not은 다른 연산자에게만 영향을 미치며 필드 및 document에 독립적으로 접근할 수 없습니다.

하려면 $ne를 써야하죠!

 

 


 

출처: $eq — MongoDB Manual

'MongoDB > Logical Query Operators' 카테고리의 다른 글

[MongoDB] $and, $nor, $or  (0) 2022.06.30