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

Function canRangeOptimize

packages/db/src/utils/index-optimization.ts:182–191  ·  view source on GitHub ↗

* Whether a range predicate (gt/gte/lt/lte) on this operand can be safely * served by the given index: the operand's domain must order the same way the * index does, and the index itself must support trustworthy range traversal * (no custom comparator).

(
  value: unknown,
  index: IndexInterface<any>,
  collection: CollectionLike<any, any>,
)

Source from the content-addressed store, hash-verified

180 * (no custom comparator).
181 */
182function canRangeOptimize(
183 value: unknown,
184 index: IndexInterface<any>,
185 collection: CollectionLike<any, any>,
186): boolean {
187 return (
188 !isRangeOrderingDivergent(value, collection) &&
189 index.supportsRangeOptimization
190 )
191}
192
193/**
194 * Optimizes a query expression using available indexes to find matching keys

Callers 2

optimizeSimpleComparisonFunction · 0.85

Calls 1

isRangeOrderingDivergentFunction · 0.85

Tested by

no test coverage detected