Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/protocol/kernel/http-protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ GET /api/data/account?filter={"status":"active"}
- `$endsWith` - String ends with
- `$between` - Between two values (tuple)
- `$null` - Null check (`{ "$null": true }` for IS NULL, `{ "$null": false }` for IS NOT NULL)
- `$exists` - Field existence check
- `$exists` - Field has a value — the inverse of `$null` (`{ "$exists": true }` is `IS NOT NULL`, `{ "$exists": false }` is `IS NULL`). Not a key-presence test: a stored `null` counts as no value on every backend, MongoDB included

**OR conditions:**
```json
Expand Down
15 changes: 13 additions & 2 deletions content/docs/protocol/objectql/query-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const query: QueryAST = {
| `$ilike` | Same pattern language, **ignoring ASCII case** | `{ name: { $ilike: '%industries' } }` |
| `$between` | Range (inclusive) | `{ close_date: { $between: ['2024-01-01', '2024-12-31'] } }` |
| `$null` | Null check | `{ manager_id: { $null: true } }` / `{ phone: { $null: false } }` |
| `$exists` | Field exists (NoSQL) | `{ metadata: { $exists: true } }` |
| `$exists` | Field has a value — the inverse of `$null` | `{ metadata: { $exists: true } }` |

### `$like` is not a spelling of `$contains`

Expand Down Expand Up @@ -514,10 +514,21 @@ where: { manager_id: { $null: true } }
// Field IS NOT NULL
where: { phone: { $null: false } }

// Field exists (NoSQL)
// Field has a value — the same rows as { $null: false }
where: { metadata: { $exists: true } }
```

<Callout type="warn">
**`$exists` is not a key-presence test.** It asks whether the field **has a
value**, so a stored `null` counts as *no value* on every backend:
`{ $exists: true }` compiles to `IS NOT NULL` and `{ $exists: false }` to
`IS NULL`. It is the exact inverse of `$null` — `{ $exists: b }` selects the
same rows as `{ $null: !b }` — and it is portable, not a NoSQL-only operator.
On MongoDB the driver lowers it to `{ $ne: null }` / `{ $eq: null }` and never
emits MongoDB's own `$exists`, which *would* have been key presence and would
have kept a `null`-valued field.
</Callout>

### Filtering Across Relationships

<Callout type="warn">
Expand Down
Loading