unionWherePredicates

Function: unionWherePredicates()

ts
function unionWherePredicates(predicates): BasicExpression<boolean>;
function unionWherePredicates(predicates): BasicExpression<boolean>;

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

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

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

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.