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

Function getTargetsFromPropRef

packages/db/src/query/compiler/lazy-targets.ts:128–160  ·  view source on GitHub ↗
(
  query: QueryIR,
  ref: PropRef,
)

Source from the content-addressed store, hash-verified

126}
127
128function getTargetsFromPropRef(
129 query: QueryIR,
130 ref: PropRef,
131): Array<LazyLoadTarget> {
132 if (ref.path.length === 0) {
133 return []
134 }
135
136 if (ref.path.length === 1) {
137 const field = ref.path[0]!
138 const selectedField = query.select?.[field]
139 if (selectedField) {
140 return getTargetsFromExpression(query, selectedField)
141 }
142 return []
143 }
144
145 const [alias, ...path] = ref.path
146 const source = getSourceFromAlias(query, alias!)
147 if (!source) {
148 return []
149 }
150
151 if (source.type === `collectionRef`) {
152 return [{ alias: source.alias, collection: source.collection, path }]
153 }
154
155 if (source.query.limit || source.query.offset) {
156 return []
157 }
158
159 return getTargetsFromQueryRef(source.query, source.alias, ref)
160}
161
162function getSourceFromAlias(
163 query: QueryIR,

Callers 2

getTargetsFromQueryRefFunction · 0.85
getTargetsFromExpressionFunction · 0.85

Calls 3

getTargetsFromExpressionFunction · 0.85
getSourceFromAliasFunction · 0.85
getTargetsFromQueryRefFunction · 0.85

Tested by

no test coverage detected