[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
});

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
...
Screenshot_2024-04-21_at_13.48.57.png
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?