Concept Flow - $eq for equality
Start Query
Check each document
Compare field value with $eq value
Include
Return matched documents
The query checks each document's field value against the $eq value. If equal, the document is included in the result.
db.collection.find({ age: { $eq: 30 } })| Step | Document | Field Value (age) | Condition (age == 30) | Result |
|---|---|---|---|---|
| 1 | { name: 'Alice', age: 25 } | 25 | 25 == 30? False | Exclude |
| 2 | { name: 'Bob', age: 30 } | 30 | 30 == 30? True | Include |
| 3 | { name: 'Carol', age: 35 } | 35 | 35 == 30? False | Exclude |
| 4 | { name: 'Dave', age: 30 } | 30 | 30 == 30? True | Include |
| 5 | No more documents | - | - | Stop |
| Variable | Start | After 1 | After 2 | After 3 | After 4 | Final |
|---|---|---|---|---|---|---|
| Current Document | None | { name: 'Alice', age: 25 } | { name: 'Bob', age: 30 } | { name: 'Carol', age: 35 } | { name: 'Dave', age: 30 } | None |
| age | N/A | 25 | 30 | 35 | 30 | N/A |
| Condition Result | N/A | False | True | False | True | N/A |
| Included in Result | N/A | No | Yes | No | Yes | N/A |
$eq operator checks if a field's value equals a specified value.
Syntax: { field: { $eq: value } }
Returns documents where field == value.
Useful for exact matches in queries.
If field missing or not equal, document excluded.