Getting started
Installation
Install drizzle-resource and check that your Drizzle setup has what the engine needs.
Requirements
- Drizzle ORM
>=1.0.0-rc.5with relational queries enabled, sodb.query.<table>.findMany(...)exists. - Your schema and relations, defined with
defineRelationsordefineRelationsPart. - TypeScript with
strict: truefor the most precise field-path types.
Install
bun add drizzle-resource
pnpm add drizzle-resource
npm install drizzle-resource
Request and response validators are separate entry points of the same package: drizzle-resource/zod, drizzle-resource/valibot and drizzle-resource/vine. Install the validator you already use; see Validation.
What the engine needs
import { createQueryEngine } from "drizzle-resource";
const engine = createQueryEngine({
db, // your Drizzle database instance
schema, // your tables, keyed by name
relations, // your Drizzle relations
});
| Option | Used for |
|---|---|
db | Running the queries. Row loading uses Drizzle's relational query API. |
schema | Deriving field paths and their types, compiling filters and sorting, reading unique constraints. |
relations | Following relation paths such as customer.name and building joins. |
The package ships its own types; there is no @types package to install.
Next: define your first resource.