Skip to content

egon-orm-workspace / egon-orm / Binding

Type Alias: Binding<S, N> ​

ts
type Binding<S, N> = { readonly [K in ColumnNames<S>]: Col<Nullify<K extends keyof Row<S> ? Row<S>[K] : never, N>> } & object;

Defined in: core/src/query/bindings.ts:53

The binding of schema S in a query: one Col per column, plus $schema (the schema class) and $alias. N is true when an outer join makes the binding's rows optional: every column is then nullable, and selecting the whole binding gives Row<S> | null.

"~binding" exists only in the type system; it is what a select reads to type a whole binding.

Type Parameters ​

S ​

S extends AnySchema

N ​

N extends boolean = false

Type Declaration ​

~binding ​

ts
readonly "~binding": object;

Type information only; there is no such property at run time.

~binding.nullable ​

ts
readonly nullable: N;

~binding.row ​

ts
readonly row: Row<S>;

$alias ​

ts
readonly $alias: string;

The binding's alias in the query.

$schema ​

ts
readonly $schema: S;

The schema class the binding was made from.

Example ​

ts
from(User, "u").where(({ u }) => u.age.gte(18)); // u: Binding<typeof User>
from(User, "u").leftJoin(Post, "p", ({ u, p }) => p.authorId.eq(u.id)); // p: Binding<typeof Post, true>