Skip to content

Class: SelectStart<TProjection>

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

Result of db.select() or db.select(projection). Delays construction of the concrete AST until .from(t) is called so the source table is known.

TProjection = NoProjection

new SelectStart<TProjection>(engine, projection): SelectStart<TProjection>

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

Engine

Projection

SelectStart<TProjection>

from<T>(t): SelectBuilder<{ [K in string]: InferRow<T> }, TProjection>

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

T extends AnyTable

T

SelectBuilder<{ [K in string]: InferRow<T> }, TProjection>


fromSubquery<TInnerBuilder>(inner, alias): SelectBuilder<Record<string, any>, TProjection>

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

Use a subquery as the FROM source. The subquery’s rows appear under the given alias so the outer query can reference columns.alias. Use for FROM (SELECT ...) AS alias shapes and CTE-style aggregations.

const active = db.select({ userId: todos.userId, cnt: count() })
.from(todos).groupBy(todos.userId)
db.select().fromSubquery(active, "active")
.where(gt(colRef("active", "cnt"), 3))

TInnerBuilder extends { $ast: SelectQuery; }

TInnerBuilder

string

SelectBuilder<Record<string, any>, TProjection>