WHERE Operators
Equality (Default)
Section titled “Equality (Default)”When you pass a plain value to .where(), it uses strict equality:
pb.from(User).where('status', 'active').find();
// Explicit equality operatorpb.from(User).where('status', { $eq: 'active' }).find();pb.from('users').where('status', 'active').find();curl ... -d '{"action":"find","table":"users","query":{"status":"active"}}'Comparison Operators
Section titled “Comparison Operators”| Operator | SQL Equivalent | TypeScript | Dart |
|---|---|---|---|
$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') |
$between | BETWEEN x AND y | { $between: [18, 65] } | between(18, 65) |
// Ages between 18 and 65pb.from(User).where('age', { $gte: 18, $lte: 65 }).find();
// Price between 10 and 100pb.from(Product).where('price', { $between: [10, 100] }).find();pb.from('users').where('age', between(18, 65)).find();pb.from('products').where('price', between(10, 100)).find();String Matching
Section titled “String Matching”| Operator | SQL Equivalent | TypeScript | Dart |
|---|---|---|---|
$like | LIKE (case-sensitive) | { $like: '%john%' } | like('%john%') |
$ilike | ILIKE (case-insensitive) | { $ilike: '%john%' } | ilike('%john%') |
// Case-insensitive searchpb.from(User).where('name', { $ilike: '%john%' }).find();pb.from('users').where('name', ilike('%john%')).find();List Operators
Section titled “List Operators”| Operator | SQL Equivalent | TypeScript | Dart |
|---|---|---|---|
$in | IN (...) | { $in: ['a', 'b'] } | isIn(['a', 'b']) |
$nin | NOT 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('users').where('role', isIn(['admin', 'moderator'])).find();pb.from('users').where('status', notIn(['banned', 'deleted'])).find();Null Checks
Section titled “Null Checks”pb.from(User).where('deleted_at', { $eq: null }).find(); // IS NULLpb.from(User).where('email', { $ne: null }).find(); // IS NOT NULLpb.from('users').where('deleted_at', isNull()).find();pb.from('users').where('email', isNotNull()).find();Full-Text Search
Section titled “Full-Text Search”// Search across multiple columnspb.from(Article).whereFts(['title', 'body'], 'typescript tutorial').find();
// With language configurationpb.from(Article) .whereFts(['title', 'body'], 'développement web', { language: 'french' }) .find();pb.from('articles').where(r'$fts', { 'fields': ['title', 'body'], 'query': 'typescript tutorial',}).find();Supported languages: english, french, german, spanish, portuguese, and all PostgreSQL pg_catalog dictionaries.
JSONB Operators
Section titled “JSONB Operators”For querying JSONB columns:
// Find where jsonb column contains a keypb.from(Event).where('metadata->type', 'click').find();
// Nested path (text extraction)pb.from(Event).where('metadata->user->id', userId).find();OR Conditions
Section titled “OR Conditions”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();curl ... -d '{"action":"find","table":"users","query":{"$or":[{"status":"active"},{"role":"admin"}]}}'Multiple AND Conditions
Section titled “Multiple AND Conditions”// All .where() calls chain with ANDpb.from(User) .where('status', 'active') .where('age', { $gte: 18 }) .where('role', { $in: ['admin', 'member'] }) .find();