import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { CreateTableBuilder } = kysely;
Calls the given function passing this
as the only argument.
Examples
db.schema
.createTable('test')
.$call((builder) => builder.addColumn('id', 'integer'))
.execute()
const addDefaultColumns = <T extends string, C extends string = never>(
builder: CreateTableBuilder<T, C>
) => {
return builder
.addColumn('id', 'integer', (col) => col.notNull())
.addColumn('created_at', 'date', (col) =>
col.notNull().defaultTo(sql`now()`)
)
.addColumn('updated_at', 'date', (col) =>
col.notNull().defaultTo(sql`now()`)
)
}
db.schema
.createTable('test')
.$call(addDefaultColumns)
.execute()
Parameters
func: (qb: this) => T