import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { ExpressionWrapper } = kysely;
Combines this
and another expression using AND
.
Also see {@link ExpressionBuilder.and}
Examples
db.selectFrom('person')
.selectAll()
.where(eb => eb('first_name', '=', 'Jennifer')
.and('last_name', '=', 'Aniston')
.and('age', '>', 40)
)
The generated SQL (PostgreSQL):
select *
from "person"
where (
"first_name" = $1
and "last_name" = $2
and "age" > $3
)
You can also pass any expression as the only argument to this method:
db.selectFrom('person')
.selectAll()
.where(eb => eb('first_name', '=', 'Jennifer')
.and(eb('first_name', '=', 'Sylvester').or('last_name', '=', 'Stallone'))
.and(eb.exists(
eb.selectFrom('pet')
.select('id')
.whereRef('pet.owner_id', '=', 'person.id')
)
)
The generated SQL (PostgreSQL):
select *
from "person"
where (
"first_name" = $1
and ("first_name" = $2 or "last_name" = $3)
and exists (
select "id"
from "pet"
where "pet"."owner_id" = "person"."id"
)
)
Type Parameters
RE extends ReferenceExpression<DB, TB>
VE extends OperandValueExpressionOrList<DB, TB, RE>
Returns
T extends SqlBool ? AndWrapper<DB, TB, SqlBool> : KyselyTypeError<"and() method can only be called on boolean expressions">
Type Parameters
E extends OperandExpression<SqlBool>
Parameters
expression: E
Returns
T extends SqlBool ? AndWrapper<DB, TB, SqlBool> : KyselyTypeError<"and() method can only be called on boolean expressions">