const myEnum = {
hello: 'HELLO',
world: 'WORLD',
} as const;
type MyEnum = typeof myEnum[keyof typeof myEnum];
export const myTable = pgTable('my_table', {
type: varchar({ length: 256 }).notNull().$type<MyEnum>(),
});
/**
* option 1 - yolo the typings
*/
const refinements = {
type: z.enum(myEnum),
} as const;
const select = createSelectSchema(myTable, refinements);
const create = createInsertSchema(myTable, refinements);
const update = createUpdateSchema(myTable, refinements);
/**
* option 2 - a complete mess
*/
const select = createSelectSchema(myTable, {
type: z.enum(myEnum),
});
const create = createInsertSchema(myTable, {
type: z.enum(myEnum),
});
const update = createUpdateSchema(myTable, {
type: z.enum(myEnum),
});
const myEnum = {
hello: 'HELLO',
world: 'WORLD',
} as const;
type MyEnum = typeof myEnum[keyof typeof myEnum];
export const myTable = pgTable('my_table', {
type: varchar({ length: 256 }).notNull().$type<MyEnum>(),
});
/**
* option 1 - yolo the typings
*/
const refinements = {
type: z.enum(myEnum),
} as const;
const select = createSelectSchema(myTable, refinements);
const create = createInsertSchema(myTable, refinements);
const update = createUpdateSchema(myTable, refinements);
/**
* option 2 - a complete mess
*/
const select = createSelectSchema(myTable, {
type: z.enum(myEnum),
});
const create = createInsertSchema(myTable, {
type: z.enum(myEnum),
});
const update = createUpdateSchema(myTable, {
type: z.enum(myEnum),
});