Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.Transaction#withTables

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

Returns a copy of this Kysely instance with tables added to its database type.

This method only modifies the types and doesn't affect any of the executed queries in any way.

Examples

The following example adds and uses a temporary table:

Examples

Example 1

await db.schema
  .createTable('temp_table')
  .temporary()
  .addColumn('some_column', 'integer')
  .execute()

const tempDb = db.withTables<{
  temp_table: {
    some_column: number
  }
}>()

await tempDb
  .insertInto('temp_table')
  .values({ some_column: 100 })
  .execute()

Type Parameters

T extends Record<string, Record<string, any>>

Returns

Transaction<DrainOuterGeneric<DB & T>>