MongoDB-compatible query language with JSON syntax. Dot notation for nested fields.
| Operator | Description | Example |
|---|---|---|
$eq | Equals | {"age": {"$eq": 30}} or just {"age": 30} |
$ne | Not equal | {"status": {"$ne": "inactive"}} |
$gt | Greater than | {"age": {"$gt": 25}} |
$gte | Greater than or equal | {"age": {"$gte": 25}} |
$lt | Less than | {"salary": {"$lt": 100000}} |
$lte | Less than or equal | {"salary": {"$lte": 100000}} |
$in | Match any in array | {"country": {"$in": ["US", "UK", "JP"]}} |
$exists | Field exists | {"email": {"$exists": true}} |
$regex | Regular expression | {"name": {"$regex": "^A", "$options": "i"}} |
| Operator | Description | Example |
|---|---|---|
$and | All conditions match | {"$and": [{"age": {"$gte": 25}}, {"status": "active"}]} |
$or | Any condition matches | {"$or": [{"city": "Tokyo"}, {"city": "Paris"}]} |
$nor | None of the conditions match v0.25.1 | {"$nor": [{"status": "banned"}, {"deleted": true}]} |
$not | Negate a field condition (missing fields → true) v0.25.1 | {"age": {"$not": {"$lt": 18}}} |
| Operator | Description | Example |
|---|---|---|
$elemMatch | Match an array element against a sub-query (AND across conditions) | {"items": {"$elemMatch": {"qty": {"$gte": 3}, "in_stock": true}}} |
$all | Array contains all listed values | {"tags": {"$all": ["sale", "new"]}} |
$size | Array has exactly this length | {"tags": {"$size": 3}} |
| Operator | Description | Example |
|---|---|---|
$type | JSON type match: string, number, int, bool, array, object, null | {"phone": {"$type": "string"}} |
$mod | Modulo arithmetic [divisor, remainder] | {"age": {"$mod": [10, 0]}} (multiples of 10) |
$expr | Top-level cross-field comparisons | {"$expr": {"$gt": ["$sold", "$stock"]}} |
{
"sort": {"age": -1, "name": 1},
"skip": 20,
"limit": 10
}
Sort values: 1 ascending, -1 descending. When an index covers the sort field, sort is O(limit) instead of O(n log n).
// Dot notation for nested access
{"address.city": "Tokyo"}
{"address.zip": {"$regex": "^0"}}
Cross-type comparisons follow a consistent ordering:
Null < Bool < Number < DateTime < String
Date strings (ISO 8601, RFC 3339, YYYY-MM-DD) are auto-detected and stored as epoch milliseconds.