Skip to content

WHERE Operators

When you pass a plain value to .where(), it uses strict equality:

pb.from(User).where('status', 'active').find();
// Explicit equality operator
pb.from(User).where('status', { $eq: 'active' }).find();
OperatorSQL EquivalentTypeScriptDart
$gt>{ $gt: 18 }gt(18)
$gte>={ $gte: 18 }gte(18)
$lt<{ $lt: 100 }lt(100)
$lte<={ $lte: 100 }lte(100)
$ne!={ $ne: 'banned' }neq('banned')
$eq={ $eq: 'active' }eq('active')
$betweenBETWEEN x AND y{ $between: [18, 65] }between(18, 65)
// Ages between 18 and 65
pb.from(User).where('age', { $gte: 18, $lte: 65 }).find();
// Price between 10 and 100
pb.from(Product).where('price', { $between: [10, 100] }).find();
OperatorSQL EquivalentTypeScriptDart
$likeLIKE (case-sensitive){ $like: '%john%' }like('%john%')
$ilikeILIKE (case-insensitive){ $ilike: '%john%' }ilike('%john%')
// Case-insensitive search
pb.from(User).where('name', { $ilike: '%john%' }).find();
OperatorSQL EquivalentTypeScriptDart
$inIN (...){ $in: ['a', 'b'] }isIn(['a', 'b'])
$ninNOT IN (...){ $nin: ['banned'] }notIn(['banned'])
pb.from(User).where('role', { $in: ['admin', 'moderator'] }).find();
pb.from(User).where('status', { $nin: ['banned', 'deleted'] }).find();
pb.from(User).where('deleted_at', { $eq: null }).find(); // IS NULL
pb.from(User).where('email', { $ne: null }).find(); // IS NOT NULL
// Search across multiple columns
pb.from(Article).whereFts(['title', 'body'], 'typescript tutorial').find();
// With language configuration
pb.from(Article)
.whereFts(['title', 'body'], 'développement web', { language: 'french' })
.find();

Supported languages: english, french, german, spanish, portuguese, and all PostgreSQL pg_catalog dictionaries.

For querying JSONB columns:

// Find where jsonb column contains a key
pb.from(Event).where('metadata->type', 'click').find();
// Nested path (text extraction)
pb.from(Event).where('metadata->user->id', userId).find();

All .where() calls are combined with AND by default. To combine with OR, use the $or key in the JSON DSL:

pb.from(User).where({
$or: [
{ status: 'active' },
{ role: 'admin' }
]
}).find();
// All .where() calls chain with AND
pb.from(User)
.where('status', 'active')
.where('age', { $gte: 18 })
.where('role', { $in: ['admin', 'member'] })
.find();