drizzle-zod sqlite enums not being able to createInsertSchemas

i can't generate insertSchamas here's my code: export const products = sqliteTable('products', { id: text().$defaultFn(() => createId()).primaryKey().notNull(), remoteId:text("remote_id"), totalQuantity:integer("total_quantity").default(0).notNull(), name:text("name").notNull(), mainImage:text("main_image").default(""), price:integer("price").notNull().default(0), codeUpc:integer("code_upc"), type:text("type",{enum:["price_per_kgs","price_per_unit"]}).notNull(), isDeleted: integer("is_deleted",{mode:"boolean"}).default(false).notNull(), isAvailable: integer("is_avaialable",{mode:"boolean"}).default(true).notNull(), createdAt: text("created_at").default(sql(CURRENT_TIMESTAMP)), updatedAt: text("updated_at").default(sql(CURRENT_TIMESTAMP)).$onUpdate(() =>sql(CURRENT_TIMESTAMP)), }) export type SelectProductType = typeof products.$inferSelect export type InsertProductType = typeof products.$inferInsert export const SelectProductSchema = createSelectSchema(products); // UI AND FORMS export const InsertProductSchema = createInsertSchema(products); export const InsertProductClientSchema = createInsertSchema(products).omit({ id: true, remoteId: true, created_at: true, updated_at: true, isDeleted:true, }).extend({ price: z.coerce.number().min(0), // Ensure price is a number and non-negative codeUpc: z.coerce.number().optional(), // Coerce codeUpc into a number if provided });
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?