JSONB Queries
Contains
Section titled “Contains”Check if a JSONB column contains a value:
pulsabase.from(User) .where('metadata', { $jsonb_contains: { role: 'admin' } }) .find();pulsabase.from('users') .where('metadata', jsonbContains({'role': 'admin'})) .find();Has Key
Section titled “Has Key”Check if a JSONB column has a specific key:
pulsabase.from(User) .where('preferences', { $jsonb_has_key: 'theme' }) .find();pulsabase.from('users') .where('preferences', jsonbHasKey('theme')) .find();Has Any Keys
Section titled “Has Any Keys”pulsabase.from('users') .where('preferences', jsonbHasAnyKey(['lang', 'timezone'])) .find();Operators Cheat Sheet
Section titled “Operators Cheat Sheet”| Operator | Description | Dart Helper |
|---|---|---|
$jsonb_contains | JSONB @> value | jsonbContains(value) |
$jsonb_has_key | JSONB ? key | jsonbHasKey(key) |
$jsonb_has_any_keys | JSONB ?| keys | jsonbHasAnyKey(keys) |