[postgres][zod] createInsertSchema

Hey! Trying to make my Sveltekit form schema. Here is my example:
export const userAccessesFormSchema = createInsertSchema(usersTable, {
id: z.string().min(1),
hasDatabase: z.boolean(),
hasMsaa: z.boolean(),
hasMsap: z.boolean()
}).pick({
id: true,
hasDatabase: true,
hasMsaa: true,
hasMsap: true
});
export const userAccessesFormSchema = createInsertSchema(usersTable, {
id: z.string().min(1),
hasDatabase: z.boolean(),
hasMsaa: z.boolean(),
hasMsap: z.boolean()
}).pick({
id: true,
hasDatabase: true,
hasMsaa: true,
hasMsap: true
});
User has many other fields, but in this case I wan't to use only these to update this user with data. Why am I getting rest of the fields in the result? I don't want to check them..Am I doing something wrong? Based on this: https://orm.drizzle.team/docs/zod Basically I need to take few fields from my User schema, make them fully required so I won't have to check after safeParse() if the value is undefined...
Drizzle ORM - drizzle-zod
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
No description
1 Reply
franek.stodulski
franek.stodulskiOP8mo ago
Like it..
No description
Want results from more Discord servers?
Add your server