Last Updated: 3/10/2026
Class AndWrapper<DB, TB, T>
An expression with an as method.
as
Type Parameters
Implements
Index
Constructors
Methods
Constructors
constructor
Type Parameters
Parameters
Returns AndWrapper<DB, TB, T>
Methods
$castTo
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.
AndWrapper
Type Parameters
Returns AndWrapper<DB, TB, C>
and
Combines this and another expression using AND.
this
AND
See ExpressionWrapper.and for examples.
Type Parameters
Parameters
Returns AndWrapper<DB, TB, T>
Combines this and another expression using AND.
this
AND
See ExpressionWrapper.and for examples.
Type Parameters
Parameters
Returns AndWrapper<DB, TB, T>
as
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:
as "the_alias"
`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_aniston)`
The generated SQL (PostgreSQL):
select "first_name" = $1 and "first_name" = $2 as "is_jennifer_aniston" from "person"
Type Parameters
Parameters
Returns AliasedExpression<T, A>
Implementation of AliasableExpression.as
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:
as "the_alias"
`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_aniston)`
The generated SQL (PostgreSQL):
select "first_name" = $1 and "first_name" = $2 as "is_jennifer_aniston" from "person"
Type Parameters
Parameters
Returns AliasedExpression<T, A>
Implementation of AliasableExpression.as
toOperationNode
Creates the OperationNode that describes how to compile this expression into SQL.
Examples
If you are creating a custom expression, it’s often easiest to use the sql template tag to build the node:
`import { type Expression, type OperationNode, sql } from ‘kysely’
class SomeExpression
get expressionType(): T | undefined {
return undefined
}
toOperationNode(): OperationNode {
return sqlsome sql here.toOperationNode()
}
}`
Returns ParensNode
Implementation of AliasableExpression.toOperationNode
Settings
On This Page
Generated using TypeDoc