$nin
Reference group: Array query operators
What it does
Matches values not in the list and also matches missing fields.
Syntax
{ field: { $nin: [values] } }
Use case
Exclude statuses.
Important notes
Use $exists if missing fields must not match.
$nin: practical example
db.products.find({ status: { $nin: ["deleted", "blocked"] } })💡 Explanation
Matches values not in the list and also matches missing fields.
When to use it
Exclude statuses.
Caution
Use
$exists if missing fields must not match.Key Takeaways
- Matches values not in the list and also matches missing fields.
- Typical use: Exclude statuses.