Skip to content

Class: SelectBuilder<TSources, TProjection>

Class: SelectBuilder<TSources, TProjection>

Section titled “Class: SelectBuilder<TSources, TProjection>”

Defined in: core/src/query/builder.ts:146

Chainable select builder. TSources accumulates per join so the returned row type is precise; TProjection is fixed at select() time and threads through unchanged. await works directly via PromiseLike.

TSources

TProjection

  • PromiseLike<SelectRow<TSources, TProjection>[]>

new SelectBuilder<TSources, TProjection>(engine, ast): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:149

Engine

SelectQuery

SelectBuilder<TSources, TProjection>

get $ast(): SelectQuery

Defined in: core/src/query/builder.ts:159

The underlying AST. Exposed so builders can be composed as subqueries via SelectStart.fromSubquery(...) — not part of the fluent API and generally not something callers touch.

SelectQuery

innerJoin<U>(u, on): SelectBuilder<{ [K in string | number | symbol]: (TSources & { [K in string]: InferRow<U> })[K] }, TProjection>

Defined in: core/src/query/builder.ts:163

U extends AnyTable

U

Expr

SelectBuilder<{ [K in string | number | symbol]: (TSources & { [K in string]: InferRow<U> })[K] }, TProjection>


leftJoin<U>(u, on): SelectBuilder<{ [K in string | number | symbol]: (TSources & { [K in string]: InferRow<U> | null })[K] }, TProjection>

Defined in: core/src/query/builder.ts:170

U extends AnyTable

U

Expr

SelectBuilder<{ [K in string | number | symbol]: (TSources & { [K in string]: InferRow<U> | null })[K] }, TProjection>


where(expr): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:186

Expr

SelectBuilder<TSources, TProjection>


orderBy(…orderings): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:191

Ordering[]

SelectBuilder<TSources, TProjection>


groupBy(…columns): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:203

Group rows by the given columns. Aggregate projections then fold once per distinct key tuple, and non-aggregated projection columns must appear in groupBy to be well-defined.

AnyColumn[]

SelectBuilder<TSources, TProjection>


having(expr): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:224

Filter groups after aggregation. Runs after groupBy — reference aggregate expressions here (e.g. having(gt(count(), 2))) rather than per-row columns.

Expr

SelectBuilder<TSources, TProjection>


limit(n): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:229

number

SelectBuilder<TSources, TProjection>


offset(n): SelectBuilder<TSources, TProjection>

Defined in: core/src/query/builder.ts:233

number

SelectBuilder<TSources, TProjection>


execute(): Promise<SelectRow<TSources, TProjection>[]>

Defined in: core/src/query/builder.ts:237

Promise<SelectRow<TSources, TProjection>[]>


live(): LiveQuery<SelectRow<TSources, TProjection>>

Defined in: core/src/query/builder.ts:241

LiveQuery<SelectRow<TSources, TProjection>>


toAST(): SelectQuery

Defined in: core/src/query/builder.ts:245

SelectQuery


then<TResult1, TResult2>(onfulfilled?, onrejected?): PromiseLike<TResult1 | TResult2>

Defined in: core/src/query/builder.ts:250

Attaches callbacks for the resolution and/or rejection of the Promise.

TResult1 = SelectRow<TSources, TProjection>[]

TResult2 = never

((value) => TResult1 | PromiseLike<TResult1>) | null

The callback to execute when the Promise is resolved.

((reason) => TResult2 | PromiseLike<TResult2>) | null

The callback to execute when the Promise is rejected.

PromiseLike<TResult1 | TResult2>

A Promise for the completion of which ever callback is executed.

PromiseLike.then