$exists
Reference group: Query filter operators
What it does
Tests field presence even when its value is null.
Syntax
{ field: { $exists: true } }
Use case
Distinguish missing from null.
$exists: practical example
db.users.find({ middleName: { $exists: false } })💡 Explanation
Tests field presence even when its value is null.
When to use it
Distinguish missing from null.
Key Takeaways
- Tests field presence even when its value is null.
- Typical use: Distinguish missing from null.