Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.CreateIndexBuilder#where

Kysely dialect for PostgreSQL using the Postgres.js client.
method kysely.CreateIndexBuilder.prototype.where
import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.3/mod.ts";
const { CreateIndexBuilder } = kysely;

Adds a where clause to the query. This Effectively turns the index partial.

Examples

import { sql } from 'kysely'

await db.schema
   .createIndex('orders_unbilled_index')
   .on('orders')
   .column('order_nr')
   .where(sql.ref('billed'), 'is not', true)
   .where('order_nr', 'like', '123%')

The generated SQL (PostgreSQL):

create index "orders_unbilled_index" on "orders" ("order_nr") where "billed" is not true and "order_nr" like '123%'

Column names specified in {@link column} or {@link columns} are known at compile-time and can be referred to in the current query and context.

Sometimes you may want to refer to columns that exist in the table but are not part of the current index. In that case you can refer to them using sql expressions.

Parameters are always sent as literals due to database restrictions.

Parameters

factory: (qb: ExpressionBuilder<ShallowRecord<string, ShallowRecord<C & string, any>>, string>) => Expression<SqlBool>