new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle ORM · all subjects

cockroach/zod

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

createSelectSchema with enum types

createSelectSchema can be used with cockroachEnum to generate a Zod schema for enum types. The resulting schema validates that values match one of the enum options defined in the enum declaration.

Refinement callback extends schema before nullability handling

When using a refinement callback function with createSelectSchema, the extension happens before the framework applies nullability and optionality rules. This means you can extend the schema with constraints like max length, and those constraints will be applied to the base type before nullability is handled.

Installation for CockroachDB Zod integration

To use Zod schemas with Drizzle ORM for CockroachDB, install drizzle-orm and zod as dependencies. Import createSelectSchema, createInsertSchema, createUpdateSchema, and createSchemaFactory from 'drizzle-orm/zod'.

Overwriting field schema with custom Zod schema example

Example of overwriting a field schema: createSelectSchema(users, { preferences: z.object({ theme: z.string() }) }) replaces the preferences field schema entirely with a custom Zod schema defining its exact structure, overriding the original nullability and type mapping.

Using extended Zod instance with createSchemaFactory

Example showing how to use an extended Zod instance: const { createInsertSchema } = createSchemaFactory({ zodInstance: z }) where z is imported from '@hono/zod-openapi' or another extended Zod library. This allows using extended methods like openapi() on generated schemas.

Give your agent this brain