MCPcopy Index your code
hub / github.com/TanStack/db / rangeQueryReversed

Method rangeQueryReversed

packages/db/src/indexes/basic-index.ts:315–335  ·  view source on GitHub ↗

* Performs a reversed range query

(options: RangeQueryOptions = {})

Source from the content-addressed store, hash-verified

313 * Performs a reversed range query
314 */
315 rangeQueryReversed(options: RangeQueryOptions = {}): Set<TKey> {
316 const { from, to, fromInclusive = true, toInclusive = true } = options
317
318 // Swap from/to and fromInclusive/toInclusive to handle reversed ranges
319 // If to is undefined, we want to start from the end (max value)
320 // If from is undefined, we want to end at the beginning (min value)
321 const swappedFrom =
322 to ??
323 (this.sortedValues.length > 0
324 ? this.sortedValues[this.sortedValues.length - 1]
325 : undefined)
326 const swappedTo =
327 from ?? (this.sortedValues.length > 0 ? this.sortedValues[0] : undefined)
328
329 return this.rangeQuery({
330 from: swappedFrom,
331 to: swappedTo,
332 fromInclusive: toInclusive,
333 toInclusive: fromInclusive,
334 })
335 }
336
337 /**
338 * Returns the next n items in sorted order

Callers

nothing calls this directly

Calls 1

rangeQueryMethod · 0.95

Tested by

no test coverage detected