A configured Knex instance.
The ObjectSchemaBuilder describing the table.
A new SchemaQueryBuilder ready for chaining.
import knex from 'knex';
import { query, object, string, number } from '@cleverbrush/knex-schema';
const UserSchema = object({ id: number(), name: string() }).hasTableName('users');
const db = knex({ client: 'pg', connection: process.env.DB_URL });
const users = await query(db, UserSchema).where(t => t.name, 'like', 'A%');
Create a typed SchemaQueryBuilder from an existing Knex query builder.
Use this overload when you need to supply a pre-configured base query — for example one that already has a sub-query, CTE, or a schema scope applied.
A configured Knex instance.
The ObjectSchemaBuilder describing the table.
An existing Knex.QueryBuilder to use as the base.
A new SchemaQueryBuilder wrapping baseQuery.
Create a typed SchemaQueryBuilder for the table described by
schema.The schema must have a table name configured via
.hasTableName(). Column name mappings set via.hasColumnName()are applied automatically to all query methods. The returned builder is thenable — you canawaitit directly to execute the query and getTResult[].