Where
Where clauses are declarative. They don’t use callbacks, they don’t generate SQL strings. Models describe metadata; they never execute logic.
Implicit equality
Section titled “Implicit equality”where: { active: true, name: "Juan",}// → WHERE active = true AND name = 'Juan'Explicit operators
Section titled “Explicit operators”where: { name: { contains: "john" }, age: { gte: 18 }, price: { lte: 100 }, id: { gte: 1, lte: 100 },}// → WHERE name LIKE '%john%' AND age >= 18 AND price <= 100 AND id BETWEEN 1 AND 100Implicit IN
Section titled “Implicit IN”where: { status: ["active", "pending"],}// → WHERE status IN ('active', 'pending')Relations
Section titled “Relations”where: { role: { name: "admin" },}// → WHERE ... role.name = 'admin'Combination
Section titled “Combination”where: { active: true, name: { contains: "john" }, role: { name: "admin" }, createdAt: { gte: new Date("2024-01-01") },}Available operators
Section titled “Available operators”| Operator | SQL | Description |
|---|---|---|
| (direct value) | = |
Equality |
contains |
LIKE |
Contains |
gte |
>= |
Greater than or equal |
lte |
<= |
Less than or equal |
gt |
> |
Greater than |
lt |
< |
Less than |
ne |
!= |
Not equal |
in |
IN |
In list |
eq |
= |
Explicit equality |
startsWith |
LIKE '...%' |
Starts with |
endsWith |
LIKE '%...' |
Ends with |
isNull |
IS NULL |
Is null |
