ZOD - how to createUpdateSchema?

What is the current workaround or alternative for the createUpdateSchema, similar to the createSelectSchema & createInsertSchema?
2 Replies
eXecuteye
eXecuteye4mo ago
i use this:
const updateSchema = createInsertSchema(tableName).pick({ name: true, ... }).partial()
const updateSchema = createInsertSchema(tableName).pick({ name: true, ... }).partial()
Kevin
KevinOP4mo ago
I have gone with
const updateMemberSchema = createInsertSchema(member, {
id: z.string().optional(),
});
const updateMemberSchema = createInsertSchema(member, {
id: z.string().optional(),
});
so basically making the primary key optional. Your version is valid as well, but I see it uncomfortable since for every new subset of columns you want to update youd have to create a new type
Want results from more Discord servers?
Add your server