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

arktype

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 validates query results against table schema

createSelectSchema generates an arktype schema from a Drizzle table that validates selected data. It checks that the returned object matches the table definition and will throw an error if required columns are missing from the query.

createInsertSchema validates data before database insertion

createInsertSchema generates an arktype schema from a Drizzle table that validates data intended to be inserted. It enforces that required fields (not auto-generated or optional) are provided. It will throw if required fields like notNull columns are missing.

createUpdateSchema validates data before database updates

createUpdateSchema generates an arktype schema from a Drizzle table that validates data intended for updates. All fields become optional, matching SQL UPDATE behavior. Generated columns cannot be updated and will cause validation errors if included.

Example: createSelectSchema with field refinements

import { pgTable, text, integer, json } from 'drizzle-orm/pg-core'; import { createSelectSchema } from 'drizzle-orm/arktype'; import { pipe, maxLength, object, string } from 'arktype'; const users = pgTable('users', { id: integer().generatedAlwaysAsIdentity().primaryKey(), name: text().notNull(), bio: text(), preferences: json() }); const userSelectSchema = createSelectSchema(users, { name: (schema) => pipe(schema, maxLength(20)), bio: (schema) => pipe(schema, maxLength(1000)), preferences: object({ theme: string() }) });

ArkErrors result type from schema validation

Schema validation functions return either ArkErrors (on validation failure) or the parsed data object (on success). Check if the result is instanceof ArkErrors to determine if validation failed, and access error details with parsed.summary.

Give your agent this brain