DB Docs
API Reference
- Core API Reference
- Collection
- createCollection
- liveQueryCollectionOptions
- createLiveQueryCollection
- createOptimisticAction
- createTransaction
- Electric DB Collection
- electricCollectionOptions
- Query DB Collection
- queryCollectionOptions
- RxDB DB Collection
- rxdbCollectionOptions
- PowerSync Collection
- powerSyncCollectionOptions
- createIndexedDB
- indexedDBCollectionOptions
- React Hooks
- useLiveQuery
AI/LLM: This documentation page is available in plain markdown format at/db/latest/docs/reference/functions/extractSimpleComparisons.md
extractSimpleComparisons
ts
function extractSimpleComparisons(expr): SimpleComparison[];Defined in: packages/db/src/query/expression-helpers.ts:337
Extracts all simple comparisons from a WHERE expression. This is useful for simple APIs that only support basic filters.
Note: This only works for simple AND-ed conditions and NOT-wrapped comparisons. Throws an error if it encounters unsupported operations like OR or complex nested expressions.
NOT operators are flattened by prefixing the operator name (e.g., not(eq(...)) becomes not_eq).
Parameters#
expr#
The WHERE expression to parse
BasicExpression<boolean> | null | undefined
Returns#
Array of simple comparisons
Throws#
Error if expression contains OR or other unsupported operations
Example#
ts
const comparisons = extractSimpleComparisons(where)
// Returns: [
// { field: ['category'], operator: 'eq', value: 'electronics' },
// { field: ['price'], operator: 'lt', value: 100 },
// { field: ['email'], operator: 'isNull' }, // No value for null checks
// { field: ['status'], operator: 'not_eq', value: 'archived' }
// ]