Type Inference from Schema in Drizzle ORM
From the Drizzle ORM cheat sheet · Schema Definition · verified Jul 2026
Type Inference from Schema
Extract TypeScript types from your Drizzle schema definitions.
typescript
import type { InferSelectModel,
InferInsertModel } from 'drizzle-orm';
import { users } from './schema';
// Infer the SELECT type (what you read from DB)
type User = InferSelectModel<typeof users>;
// Infer the INSERT type (what you write to DB)
type NewUser = InferInsertModel<typeof users>;💡 InferSelectModel = what DB returns on select
⚡ InferInsertModel makes defaults optional
📌 Use these types in your app layer for safety
🟢 Also available as users.$inferSelect shorthand
schematypesinference