Change the output type of the expression.
This method call doesn't change the SQL in any way. This methods simply
returns a copy of this AndWrapper
with a new output type.
Combines this
and another expression using AND
.
See and for examples.
Returns an aliased version of the expression.
In addition to slapping as "the_alias"
to the end of the SQL,
this method also provides strict typing:
const result = await db
.selectFrom('person')
.select(eb =>
eb('first_name', '=', 'Jennifer')
.and('last_name', '=', 'Aniston')
.as('is_jennifer_aniston')
)
.executeTakeFirstOrThrow()
// `is_jennifer_aniston: SqlBool` field exists in the result type.
console.log(result.is_jennifer_or_sylvester)
The generated SQL (PostgreSQL):
select "first_name" = $1 and "first_name" = $2 as "is_jennifer_aniston"
from "person"
Creates the OperationNode that describes how to compile this expression into SQL.
If you are creating a custom expression, it's often easiest to use the sql template tag to build the node:
class SomeExpression<T> implements Expression<T> {
toOperationNode(): OperationNode {
return sql`some sql here`.toOperationNode()
}
}
Generated using TypeDoc
An expression with an
as
method.