Learn MongoDB-style query syntax by writing real queries against a live dataset — powered by the actual sift library, running entirely in your browser.
Mental model in one line: a query is a JSON object, and every $operator is a little yes/no test.
No $ on a key = "this field equals this value". A $ key = "apply this test". Stack keys and they all must pass (implicit AND).
| You write… | It means… |
|---|---|
{ field: value } | field equals value (implicit $eq) |
{ field: { $op: x } } | run test $op against field |
{ a: 1, b: 2 } | a===1 AND b===2 (all keys must pass) |
{ "a.b.c": x } | dive into nested objects with dots… |
{ "tags.name": x } | …and it auto-searches every element if the path hits an array |
{ field: (v) => bool } | escape hatch: any function as a predicate |
✅ = implemented in sift. Mnemonics in the last column.
| Operator | Meaning | Mini example | Remember it as… |
|---|---|---|---|
$eq / $ne | equals / not equals | { rank: { $ne: "C" } } | "EQuals / Not Equal" |
$gt $gte $lt $lte | >, ≥, <, ≤ | { level: { $gte: 64 } } | Greater/Less Than (+E = "or Equal") |
$in / $nin | is / isn't in a list | { rank: { $in: ["S","A"] } } | "IN the guest list / Not IN" |
$and $or $nor | all / any / none of these | { $or: [ {rank:"S"}, {gold:{$lt:100}} ] } | boolean glue (takes an array) |
$not | invert a single test | { element: { $not: { $eq: "ice" } } } | "flip it" |
$exists | field present (or not) | { gold: { $exists: false } } | "is the field even there?" |
$type | value is of a type | { joined: { $type: Date } } | pass a constructor or "string"… |
$regex (+$options) | string matches pattern | { name: { $regex: "^Z", $options: "i" } } | "text search" |
$mod | value % divisor === remainder | { level: { $mod: [2, 0] } } | [divisor, remainder] → even=[2,0] |
$size | array has exactly N elements | { potions: { $size: 2 } } | "how long is the array?" |
$all | array contains all of these | { tags: { $all: ["tank","veteran"] } } | "must have ALL" |
$elemMatch | ≥1 array element matches a sub-query | { potions: { $elemMatch: { kind:"heal", qty:{$gte:5} } } } | "one element satisfies the WHOLE inner query" |
$where | raw JS expression (⚠ eval) | { $where: "this.level > 80" } | last resort |
Not in sift: $expr, $jsonSchema, bitwise ($bitsAllSet…), geospatial ($near…).
Ctrl/⌘+Enter). You're graded on whether your query selects the right hunters, so many different correct queries pass.Equality, comparisons, $in, and stacking conditions. These are ~80% of real-world queries.
$and/$or/$nor, $nin, $regex, $exists, $size — composing real filters.
$elemMatch, $all, dot-paths into arrays, $not, $mod, dates — the tricky stuff.
Write any query object and run it against the full roster. Great for testing an idea before answering a quiz.
Runs the real sift v17.1.3 bundle, inlined — works offline. Your progress is saved in this browser. Companion to the sift.js Internal Guide.