UNPKG

drizzle-cuid2

Version:

A utility package for generating CUID2 columns in Drizzle ORM

33 lines (29 loc) 1.48 kB
import { ColumnBuilderBaseConfig, entityKind, MakeColumnConfig, HasDefault, ColumnBaseConfig } from 'drizzle-orm'; import { SQLiteColumnBuilder, AnySQLiteTable, SQLiteColumn } from 'drizzle-orm/sqlite-core'; type SQLiteCuid2BuilderInitial<TName extends string> = Omit<SQLiteCuid2Builder<{ name: TName; dataType: 'string'; columnType: 'SQLiteCuid2'; data: string; driverParam: string; enumValues: undefined; }>, 'default' | '$default' | '$defaultFn'>; declare class SQLiteCuid2Builder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteCuid2'>> extends SQLiteColumnBuilder<T> { static readonly [entityKind]: string; constructor(name: string); build<TTableName extends string>(table: AnySQLiteTable<{ name: TTableName; }>): SQLiteCuid2<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 SQLiteCuid2<T extends ColumnBaseConfig<'string', 'SQLiteCuid2'>> extends SQLiteColumn<T> { static readonly [entityKind]: string; getSQLType(): string; } declare function cuid2(): SQLiteCuid2BuilderInitial<''>; declare function cuid2<TName extends string>(name: TName): SQLiteCuid2BuilderInitial<TName>; export { SQLiteCuid2, SQLiteCuid2Builder, type SQLiteCuid2BuilderInitial, cuid2 };