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

Function wrapInputWithAlias

packages/db/src/query/compiler/index.ts:1263–1281  ·  view source on GitHub ↗
(
  input: KeyedStream,
  alias: string,
)

Source from the content-addressed store, hash-verified

1261}
1262
1263function wrapInputWithAlias(
1264 input: KeyedStream,
1265 alias: string,
1266): NamespacedAndKeyedStream {
1267 return input.pipe(
1268 map(([key, row]) => {
1269 // Initialize the record with a nested structure.
1270 // If __parentContext exists (from parent-referencing includes), merge parent
1271 // aliases into the namespaced row so WHERE can resolve parent refs.
1272 const { __parentContext, ...cleanRow } = row as any
1273 const nsRow: Record<string, any> = { [alias]: cleanRow }
1274 if (__parentContext) {
1275 Object.assign(nsRow, __parentContext)
1276 ;(nsRow as any).__parentContext = __parentContext
1277 }
1278 return [key, nsRow] as [unknown, Record<string, typeof row>]
1279 }),
1280 )
1281}
1282
1283function encodeKeyForUnionBranch(key: unknown): string {
1284 if (typeof key === `string`) {

Callers 2

compileQueryFunction · 0.85
processFromClauseFunction · 0.85

Calls 2

mapFunction · 0.90
pipeMethod · 0.80

Tested by

no test coverage detected