CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
foreign-keys.d.cts49 linesDownload Raw Back to gel-core
1import { entityKind } from "../entity.cjs";2import type { AnyGelColumn, GelColumn } from "./columns/index.cjs";3import type { GelTable } from "./table.cjs";4export type UpdateDeleteAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';5export type Reference = () => {6    readonly name?: string;7    readonly columns: GelColumn[];8    readonly foreignTable: GelTable;9    readonly foreignColumns: GelColumn[];10};11export declare class ForeignKeyBuilder {12    static readonly [entityKind]: string;13    constructor(config: () => {14        name?: string;15        columns: GelColumn[];16        foreignColumns: GelColumn[];17    }, actions?: {18        onUpdate?: UpdateDeleteAction;19        onDelete?: UpdateDeleteAction;20    } | undefined);21    onUpdate(action: UpdateDeleteAction): this;22    onDelete(action: UpdateDeleteAction): this;23}24export type AnyForeignKeyBuilder = ForeignKeyBuilder;25export declare class ForeignKey {26    readonly table: GelTable;27    static readonly [entityKind]: string;28    readonly reference: Reference;29    readonly onUpdate: UpdateDeleteAction | undefined;30    readonly onDelete: UpdateDeleteAction | undefined;31    constructor(table: GelTable, builder: ForeignKeyBuilder);32    getName(): string;33}34type ColumnsWithTable<TTableName extends string, TColumns extends GelColumn[]> = {35    [Key in keyof TColumns]: AnyGelColumn<{36        tableName: TTableName;37    }>;38};39export declare function foreignKey<TTableName extends string, TForeignTableName extends string, TColumns extends [AnyGelColumn<{40    tableName: TTableName;41}>, ...AnyGelColumn<{42    tableName: TTableName;43}>[]]>(config: {44    name?: string;45    columns: TColumns;46    foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;47}): ForeignKeyBuilder;48export {};49