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

Function compileSingleRowRef

packages/db/src/query/compiler/evaluators.ts:216–230  ·  view source on GitHub ↗

* Compiles a reference expression for single-row evaluation

(ref: PropRef)

Source from the content-addressed store, hash-verified

214 * Compiles a reference expression for single-row evaluation
215 */
216function compileSingleRowRef(ref: PropRef): CompiledSingleRowExpression {
217 const propertyPath = ref.path
218
219 // This function works for all path lengths including empty path
220 return (item) => {
221 let value: any = item
222 for (const prop of propertyPath) {
223 if (value == null) {
224 return value
225 }
226 value = value[prop]
227 }
228 return value
229 }
230}
231
232/**
233 * Compiles a function expression for both namespaced and single-row evaluation

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected