Module

x/kysely_postgrs_js_dialect/deps.ts>kysely.ExpressionWrapper#and

Kysely dialect for PostgreSQL using the Postgres.js client.
method kysely.ExpressionWrapper.prototype.and
import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.3/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"
  )
)

Returns

T extends SqlBool ? AndWrapper<DB, TB, SqlBool> : KyselyTypeError<"and() method can only be called on boolean expressions">

Parameters

expression: E

Returns

T extends SqlBool ? AndWrapper<DB, TB, SqlBool> : KyselyTypeError<"and() method can only be called on boolean expressions">