drizzle-zero
Version:
Generate Zero schemas from Drizzle ORM schemas
18 lines (15 loc) • 1.1 kB
TypeScript
import { DBConnection, Row, DBTransaction } from '@rocicorp/zero/pg';
import { PgTransaction } from 'drizzle-orm/pg-core';
import { PostgresJsDatabase, PostgresJsQueryResultHKT } from 'drizzle-orm/postgres-js';
import { ExtractTablesWithRelations } from 'drizzle-orm/relations';
import postgres from 'postgres';
type PostgresJsZeroTransaction<TDatabase extends PostgresJsDatabase<Record<string, unknown>>> = Parameters<Parameters<TDatabase["transaction"]>[0]>[0] & {};
declare class PostgresJsConnection<TDrizzle extends PostgresJsDatabase<Record<string, unknown>> & {
$client: postgres.Sql<{}>;
}, TSchema extends TDrizzle extends PostgresJsDatabase<infer TSchema> ? TSchema : never, TTransaction extends PgTransaction<PostgresJsQueryResultHKT, TSchema, ExtractTablesWithRelations<TSchema>>> implements DBConnection<TTransaction> {
#private;
constructor(drizzle: TDrizzle);
query(sql: string, params: unknown[]): Promise<Row[]>;
transaction<T>(fn: (tx: DBTransaction<TTransaction>) => Promise<T>): Promise<T>;
}
export { PostgresJsConnection, type PostgresJsZeroTransaction };