Key Takeaways About $nin Operator
- The
$nin
operator is used to select documents where the value of a field is not equal to any of the given values in an array.- The operator can be used to filter documents based on the non-existence of a field or the non-matching of a field value with any of the specified array values.
- The
$nin
operator supports different BSON types and can be used in various methods likefind()
,update()
, etc.- The
$nin
operator supports Type Bracketing for limited cross-BSON comparison.
MongoDB – $nin Operator
MongoDB $nin or ” not in” is one of the comparison query operators. The $nin operator selects those documents where the field value is not equal to any of the given values in the array and the field that does not exist.
You can use this operator in methods like find()
, update()
, etc. according to your requirements.
Contact Us