interface kysely.AliasedExpression
implements OperationNodeSource
Re-export
import { type kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { AliasedExpression } = kysely;
A type that holds an expression and an alias for it.
AliasedExpression<T, A>
can be used in places where, in addition to the value type T
, you
also need a name A
for that value. For example anything you can pass into the select
method
needs to implement an AliasedExpression<T, A>
. A
becomes the name of the selected expression
in the result and T
becomes its type.
Examples
Example 1
Example 1
class SomeAliasedExpression<T, A extends string> implements AliasedExpression<T, A> {
#expression: Expression<T>
#alias: A
constructor(expression: Expression<T>, alias: A) {
this.#expression = expression
this.#alias = alias
}
get expression(): Expression<T> {
return this.#expression
}
get alias(): A {
return this.#alias
}
toOperationNode(): AliasNode {
return AliasNode.create(this.#expression.toOperationNode(), IdentifierNode.create(this.#alias))
}
}
Methods
getter
expression(): Expression<T>Returns the aliased expression.
getter
alias(): A | Expression<unknown>Returns the alias.
toOperationNode(): AliasNode
Creates the OperationNode that describes how to compile this expression into SQL.