UNPKG

agnostic-query

Version:

Type-safe fluent builder for portable query schemas. Runtime-agnostic, database-agnostic — the same QuerySchema drives Drizzle, Kysely, db0, or raw SQL.

15 lines (14 loc) 963 B
import type { ExpressionBuilder, SqlBool } from 'kysely'; import { type ExpressionWrapper } from 'kysely'; import type { QueryOrderBy } from '../core/order-by.js'; import type { QueryWhere } from '../core/where.js'; import type { TSelectQueryBuilder } from './types.js'; type Expression<TShape, TableName extends string> = ExpressionBuilder<{ [k in TableName]: TShape; }, TableName>; type BuildResult<TShape, TableName extends string> = (expression: Expression<TShape, TableName>) => ExpressionWrapper<{ [k in TableName]: TShape; }, TableName, SqlBool>; export declare const toKyselyWhere: <TShape extends Record<string, any>, TableName extends string>(where?: QueryWhere<TShape> | null) => BuildResult<TShape, TableName>; export declare const toKyselyOrderBy: <TShape extends Record<string, any>, TableName extends string>(q: TSelectQueryBuilder<TShape, TableName>, orderBy?: QueryOrderBy<TShape>[]) => TSelectQueryBuilder<TShape, TableName>; export {};