Filtering
Special Operators
Range queries with between and combining multiple filter operators.
Special operators handle range queries and combine with other filter operators.
For null and absence checks (isNull, isNone, isDefined), see Null & None.
Operator Availability
| Operator | Available on | Checks for |
|---|---|---|
between | Numeric, Date, String fields | Inclusive range [min, max] |
See Null & None for isNull, isNone, and isDefined operator availability.
between
Performs an inclusive range check. The value must be a two-element tuple [min, max]:
const users = await client.db.User.findMany({
where: { age: { between: [18, 65] } },
});
// Matches: 18 <= age <= 65With Numbers
const products = await client.db.Product.findMany({
where: { price: { between: [10.0, 99.99] } },
});With Dates
const posts = await client.db.Post.findMany({
where: {
createdAt: {
between: [new Date('2024-01-01'), new Date('2024-12-31')],
},
},
});With Strings
String ranges use lexicographic ordering:
const users = await client.db.User.findMany({
where: { name: { between: ['A', 'M'] } },
});
// Matches names from 'A' through 'M' (inclusive)Combining Special Operators
Special operators can be combined with all other filter operators in the same where clause:
const users = await client.db.User.findMany({
where: {
age: { between: [18, 65] },
deletedAt: { isNull: true },
bio: { isNone: false },
status: { neq: 'banned' },
},
});They also work with logical operators:
const users = await client.db.User.findMany({
where: {
OR: [
{ bio: { isNone: true } },
{ bio: { isNull: true } },
],
},
});
// Matches users who either have no bio field or have bio set to null
// (only valid on fields with both ? and @nullable)