Something went wrong. Try again.
A fluent interface implementation for creating different SQLite queries in TypeScript without having to write SQL directly.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import type { PrimaryKey, AlternateKey, ForeignKey, Table } from "../types.ts";
import { type IfNotExistsTransition, ifNotExistsTransition, type WithForeignKeyColumnTransition, withForeignKeyColumnTransition, type WithOptionalColumnTransition, withOptionalColumnTransition, type WithPrimaryKeyColumnTransition, withPrimaryKeyColumnTransition, type WithRequiredColumnTransition, withRequiredColumnTransition,} from "../transitions/index.ts";
export interface CreateTemporaryTable< TPrimaryKey extends Record<string, PrimaryKey> = Record<string, never>, TAlternateKeys extends Record<string, AlternateKey> = Record<string, never>, TForeignKeys extends Record<string, ForeignKey> = Record<string, never>,> { table: Table<TPrimaryKey, TAlternateKeys, TForeignKeys>; ifNotExists: IfNotExistsTransition<TPrimaryKey, TAlternateKeys, TForeignKeys>; withPrimaryKeyColumn: WithPrimaryKeyColumnTransition< TPrimaryKey, TAlternateKeys, TForeignKeys >; withRequiredColumn: WithRequiredColumnTransition< TPrimaryKey, TAlternateKeys, TForeignKeys >; withOptionalColumn: WithOptionalColumnTransition< TPrimaryKey, TAlternateKeys, TForeignKeys >; withForeignKeyColumn: WithForeignKeyColumnTransition< TPrimaryKey, TAlternateKeys, TForeignKeys >;}
export function createTemporaryTable< TPrimaryKey extends Record<string, PrimaryKey>, TAlternateKeys extends Record<string, AlternateKey>, TForeignKeys extends Record<string, ForeignKey>,>( name: string, schema?: string,): CreateTemporaryTable<TPrimaryKey, TAlternateKeys, TForeignKeys> { const table = { name, schema, isTemporary: true, createIfNotExists: false, primaryKey: {}, alternateKeys: {}, foreignKeys: {}, } as Table<TPrimaryKey, TAlternateKeys, TForeignKeys>;
return { table, ifNotExists: ifNotExistsTransition(table), withPrimaryKeyColumn: withPrimaryKeyColumnTransition(table), withRequiredColumn: withRequiredColumnTransition(table), withOptionalColumn: withOptionalColumnTransition(table), withForeignKeyColumn: withForeignKeyColumnTransition(table), };}