Skip to main content
Module

x/kysely_deno_postgres_dialect/mod.ts>kysely.AliasedExpression

Kysely dialect for PostgreSQL using the deno-postgres client.
Latest
interface kysely.AliasedExpression
Re-export
import { type kysely } from "https://deno.land/x/kysely_deno_postgres_dialect@v0.27.1/mod.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

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))
  }
}

Type Parameters

T
A extends string

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.