Skip to content
Source
Sign inSign up
TanStack/db

feat: add materialize() helper for includes subqueries #1504

Mergedkevin-dp(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/1504/headmerged by kevin-dp(GitHub profile, opens in a new tab)

Showing 9 changed files with 72 additions and 5 deletions (loading 6).

x
0 of 9 viewed, 9 left
51 additions and 0 deletionspackages/db/src/query/builder/functions.tsModified
View file
@@ -2,6 +2,7 @@
import { isRefProxy, toExpression } from './ref-proxy.js'
import type { BasicExpression } from '../ir'
import type { RefProxy } from './ref-proxy.js'
+import type { SingleResult } from '../../types.js'
import type {
Context,
GetRawResult,
@@ -723,6 +724,17 @@
constructor(public readonly args: Array<CaseWhenValue>) {}
​
+export class MaterializeWrapper<
+ _T = unknown,
+ _IsSingle extends boolean = boolean,
+> {
+ readonly __brand = `MaterializeWrapper` as const
+ declare readonly _type: `materialize`
+ declare readonly _result: _T
+ declare readonly _isSingle: _IsSingle
+ constructor(public readonly query: QueryBuilder<any>) {}
+}
+​
export function toArray<TContext extends Context>(
query: QueryBuilder<TContext>,