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

Method unionAll

packages/db/src/query/builder/index.ts:207–233  ·  view source on GitHub ↗
(
    sourceOrBranch: Source | QueryBuilder<any>,
    ...branches: Array<QueryBuilder<any>>
  )

Source from the content-addressed store, hash-verified

205 TBranches extends readonly [QueryBuilder<any>, ...Array<QueryBuilder<any>>],
206 >(...branches: TBranches): QueryBuilder<ContextFromUnionBranches<TBranches>>
207 unionAll(
208 sourceOrBranch: Source | QueryBuilder<any>,
209 ...branches: Array<QueryBuilder<any>>
210 ): QueryBuilder<any> {
211 if (sourceOrBranch instanceof BaseQueryBuilder) {
212 return new BaseQueryBuilder({
213 ...this.query,
214 from: new UnionAll(
215 [sourceOrBranch, ...branches].map((branch) =>
216 (branch as unknown as BaseQueryBuilder)._getQuery(),
217 ),
218 ),
219 }) as any
220 }
221
222 const refs = this._createRefsForSource(
223 sourceOrBranch as Source,
224 UNION_ALL_SOURCE_CONTEXT,
225 )
226 const from =
227 refs.length === 1 ? refs[0]![1] : new UnionFrom(refs.map((r) => r[1]))
228
229 return new BaseQueryBuilder({
230 ...this.query,
231 from,
232 }) as any
233 }
234
235 /**
236 * Join another table or subquery to the current query

Callers 3

union-all.test.tsFile · 0.80
union-all.test.tsFile · 0.80

Calls 3

_createRefsForSourceMethod · 0.95
_getQueryMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected