Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

unionWherePredicates.md

42 lines1.1 KB

Function: unionWherePredicates()

function unionWherePredicates(predicates): BasicExpression<boolean>;

Defined in: packages/db/src/query/predicate-utils.ts:328

Combine multiple where predicates with OR logic (union). Returns a predicate that is satisfied when any input predicate is satisfied. Simplifies when possible (e.g., age > 10 OR age > 20 → age > 10).

Parameters

predicates

BasicExpression<boolean>[]

Array of where predicates to union

Returns

BasicExpression<boolean>

Combined predicate representing the union

Examples

// Take least restrictive
unionWherePredicates([gt(ref('age'), val(10)), gt(ref('age'), val(20))]) // age > 10
// Combine equals into IN
unionWherePredicates([eq(ref('age'), val(5)), eq(ref('age'), val(10))]) // age IN [5, 10]