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

Function collectRefs

packages/db/src/query/optimizer.ts:1085–1105  ·  view source on GitHub ↗

* Recursively collects all PropRef references from an expression. * * @param expr - The expression to traverse * @returns Array of PropRef references found in the expression

(expr: any)

Source from the content-addressed store, hash-verified

1083 * @returns Array of PropRef references found in the expression
1084 */
1085function collectRefs(expr: any): Array<PropRef> {
1086 const refs: Array<PropRef> = []
1087
1088 if (expr == null || typeof expr !== `object`) return refs
1089
1090 switch (expr.type) {
1091 case `ref`:
1092 refs.push(expr as PropRef)
1093 break
1094 case `func`:
1095 case `agg`:
1096 for (const arg of expr.args ?? []) {
1097 refs.push(...collectRefs(arg))
1098 }
1099 break
1100 default:
1101 break
1102 }
1103
1104 return refs
1105}
1106
1107/**
1108 * Determines whether the provided WHERE clause references fields that are

Calls

no outgoing calls

Tested by

no test coverage detected