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

Function createSelectedProxy

packages/db/src/query/builder/ref-proxy.ts:214–251  ·  view source on GitHub ↗
(path: Array<string>)

Source from the content-addressed store, hash-verified

212 const cache = new Map<string, any>()
213
214 function createSelectedProxy(path: Array<string>): any {
215 const pathKey = path.join(`.`)
216 if (cache.has(pathKey)) {
217 return cache.get(pathKey)
218 }
219
220 const proxy = new Proxy({} as any, {
221 get(target, prop, receiver) {
222 if (prop === `__refProxy`) return true
223 if (prop === `__path`) return [`$selected`, ...path]
224 if (prop === `__type`) return undefined
225 if (typeof prop === `symbol`) return Reflect.get(target, prop, receiver)
226
227 const newPath = [...path, String(prop)]
228 return createSelectedProxy(newPath)
229 },
230
231 has(target, prop) {
232 if (prop === `__refProxy` || prop === `__path` || prop === `__type`)
233 return true
234 return Reflect.has(target, prop)
235 },
236
237 ownKeys(target) {
238 return Reflect.ownKeys(target)
239 },
240
241 getOwnPropertyDescriptor(target, prop) {
242 if (prop === `__refProxy` || prop === `__path` || prop === `__type`) {
243 return { enumerable: false, configurable: true }
244 }
245 return Reflect.getOwnPropertyDescriptor(target, prop)
246 },
247 })
248
249 cache.set(pathKey, proxy)
250 return proxy
251 }
252
253 const wrappedSelectedProxy = createSelectedProxy([])
254

Callers 2

getFunction · 0.85

Calls 4

joinMethod · 0.45
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…