UNPKG

drizzle-cuid2

Version:

A utility package for generating CUID2 columns in Drizzle ORM

33 lines (29 loc) 1.4 kB
import { ColumnBuilderBaseConfig, entityKind, MakeColumnConfig, HasDefault, ColumnBaseConfig } from 'drizzle-orm'; import { PgColumnBuilder, AnyPgTable, PgColumn } from 'drizzle-orm/pg-core'; type PgCuid2BuilderInitial<TName extends string> = Omit<PgCuid2Builder<{ name: TName; dataType: 'string'; columnType: 'PgCuid2'; data: string; driverParam: string; enumValues: undefined; }>, 'default' | '$default' | '$defaultFn'>; declare class PgCuid2Builder<T extends ColumnBuilderBaseConfig<'string', 'PgCuid2'>> extends PgColumnBuilder<T> { static readonly [entityKind]: string; constructor(name: T['name']); build<TTableName extends string>(table: AnyPgTable<{ name: TTableName; }>): PgCuid2<MakeColumnConfig<T, TTableName>>; /*** * Creates a random `cuid2` value as the default value for the column. * The function will be called when the row is inserted, and the returned value will be used as the column value. */ defaultRandom(): HasDefault<this>; } declare class PgCuid2<T extends ColumnBaseConfig<'string', 'PgCuid2'>> extends PgColumn<T> { static readonly [entityKind]: string; getSQLType(): string; } declare function cuid2(): PgCuid2BuilderInitial<''>; declare function cuid2<TName extends string>(name: TName): PgCuid2BuilderInitial<TName>; export { PgCuid2, PgCuid2Builder, type PgCuid2BuilderInitial, cuid2 };