custom datatypes

Let's say I have
features: text().array().notNull().default(sql`ARRAY[]::text[]`),
features: text().array().notNull().default(sql`ARRAY[]::text[]`),
but I want to shorten this to textArray(). I'd assume this should be as easy as
extern function textArray() {
return text().array().notNull().default(sql`ARRAY[]::text[]`)
}
extern function textArray() {
return text().array().notNull().default(sql`ARRAY[]::text[]`)
}
but what is the correct type? Especially when looking at more complicated shorthands like
export function ref(
id: AnyPgColumn,
options?: { onDelete: 'cascade' | 'set null' | 'restrict' }
): PgBigInt53BuilderInitial<''> {
return bigint({ mode: 'number' }).references((): AnyPgColumn => id, options);
}
export function ref(
id: AnyPgColumn,
options?: { onDelete: 'cascade' | 'set null' | 'restrict' }
): PgBigInt53BuilderInitial<''> {
return bigint({ mode: 'number' }).references((): AnyPgColumn => id, options);
}
I can't get it to be a transparent pass through as ref() does not allow for adding notNull(). Any pointers for reducing the verbosity with some helper functions?
1 Reply
tcurdt
tcurdtOP2mo ago
anyone?
Want results from more Discord servers?
Add your server