Overview
Comparison operators enable precise filtering of nodes based on field values. These operators work withdb.map() queries and support numbers, strings, dates, and arrays.
Operators
$eq - Equals
Matches nodes where the field equals the specified value.$ne - Not Equals
Matches nodes where the field does not equal the specified value.$gt - Greater Than
Matches nodes where the field is greater than the specified value.$gte - Greater Than or Equal
Matches nodes where the field is greater than or equal to the specified value.$lt - Less Than
Matches nodes where the field is less than the specified value.$lte - Less Than or Equal
Matches nodes where the field is less than or equal to the specified value.$in - In Array
Matches nodes where the field value is in the specified array.$between - Range
Matches nodes where the field value falls between two values (inclusive).$exists - Field Existence
Matches nodes where the field exists (or doesn’t exist).Examples
Age Range Query
Price Filter
Status Filtering
Multi-Role Query
File Size Filter
Date Range Queries
Combining Multiple Operators
Real-Time Price Monitoring
Inventory Management
Operator Combinations
You can combine multiple operators on the same field using logical operators:
Type Support
| Operator | Numbers | Strings | Dates | Booleans | Arrays |
|---|---|---|---|---|---|
| $eq | ✅ | ✅ | ✅ | ✅ | ✅ |
| $ne | ✅ | ✅ | ✅ | ✅ | ✅ |
| $gt | ✅ | ✅ | ✅ | ❌ | ❌ |
| $gte | ✅ | ✅ | ✅ | ❌ | ❌ |
| $lt | ✅ | ✅ | ✅ | ❌ | ❌ |
| $lte | ✅ | ✅ | ✅ | ❌ | ❌ |
| $in | ✅ | ✅ | ✅ | ✅ | ✅ |
| $between | ✅ | ✅ | ✅ | ❌ | ❌ |
| $exists | ✅ | ✅ | ✅ | ✅ | ✅ |
Best Practices
Related Operators
- Text Search Operators - $text for full-text search
- Logical Operators - or, $not
- Graph Traversal - $edge for relationships