MCPcopy Create free account
hub / github.com/TanStack/db / findPredicateWithOperator

Function findPredicateWithOperator

packages/db/src/query/predicate-utils.ts:1034–1047  ·  view source on GitHub ↗

* Find a predicate with a specific operator and value

(
  predicates: Array<BasicExpression<boolean>>,
  operator: string,
  value: any,
)

Source from the content-addressed store, hash-verified

1032 * Find a predicate with a specific operator and value
1033 */
1034function findPredicateWithOperator(
1035 predicates: Array<BasicExpression<boolean>>,
1036 operator: string,
1037 value: any,
1038): BasicExpression<boolean> | undefined {
1039 return predicates.find((p) => {
1040 if (p.type === `func`) {
1041 const f = p as Func
1042 const field = extractComparisonField(f)
1043 return f.name === operator && field && areValuesEqual(field.value, value)
1044 }
1045 return false
1046 })
1047}
1048
1049function areExpressionsEqual(a: BasicExpression, b: BasicExpression): boolean {
1050 if (a.type !== b.type) {

Callers 1

unionSameFieldPredicatesFunction · 0.85

Calls 2

extractComparisonFieldFunction · 0.85
areValuesEqualFunction · 0.70

Tested by

no test coverage detected