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

Method lookup

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

* Performs a lookup operation

(operation: IndexOperation, value: any)

Source from the content-addressed store, hash-verified

202 * Performs a lookup operation
203 */
204 lookup(operation: IndexOperation, value: any): Set<TKey> {
205 const startTime = performance.now()
206
207 let result: Set<TKey>
208
209 switch (operation) {
210 case `eq`:
211 result = this.equalityLookup(value)
212 break
213 case `gt`:
214 result = this.rangeQuery({ from: value, fromInclusive: false })
215 break
216 case `gte`:
217 result = this.rangeQuery({ from: value, fromInclusive: true })
218 break
219 case `lt`:
220 result = this.rangeQuery({ to: value, toInclusive: false })
221 break
222 case `lte`:
223 result = this.rangeQuery({ to: value, toInclusive: true })
224 break
225 case `in`:
226 result = this.inArrayLookup(value)
227 break
228 default:
229 throw new Error(`Operation ${operation} not supported by BasicIndex`)
230 }
231
232 this.trackLookup(startTime)
233 return result
234 }
235
236 /**
237 * Gets the number of indexed keys

Callers 2

optimizeSimpleComparisonFunction · 0.45

Calls 3

equalityLookupMethod · 0.95
rangeQueryMethod · 0.95
inArrayLookupMethod · 0.95

Tested by

no test coverage detected