nnestjs-drizzle-crud
Getting started

Installation

Install nestjs-drizzle-crud and the required peer dependencies for your database.

Package

pnpm add nestjs-drizzle-crud

Latest version: 3.2.2. The package is published under nestjs-drizzle-crud on npm. A CHANGELOG.md is shipped in the npm tarball and mirrored at Changelog.

Peer dependencies

The package is unopinionated about which database driver you use. Install only what you need.

Always required

pnpm add @nestjs/common @nestjs/core drizzle-orm reflect-metadata

PostgreSQL: required only if you use connectionString

When you pass connectionString to forRoot({ dialect: 'postgresql' }), the module builds the Drizzle connection itself using the postgres driver.

pnpm add postgres

pnpm enforces peer dependencies strictly. If you let the module build the connection from a connectionString, make sure postgres is installed in your app, otherwise the build will fail with a missing-peer error.

MySQL: required (always, for MySQL)

MySQL has no RETURNING support, so the package can't build a connection for you from a connection string. You must install mysql2 and pass a pre-built db to forRoot. See the forRoot guide for the full pattern.

pnpm add mysql2

If you pre-build the Drizzle instance (any dialect)

If you build the Drizzle instance yourself and pass it to forRoot as db, you can skip the module's internal driver setup entirely, which means you do not need postgres even on PostgreSQL.

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

DrizzleCrudModule.forRoot({
  dialect: 'postgresql',
  db: drizzle(postgres(process.env.DATABASE_URL!), { schema }),
});

This is also the recommended pattern for MySQL.

TypeScript configuration

The package relies on Reflect.getMetadata to read per-service configuration. Make sure your tsconfig.json enables decorators:

tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Versioning policy

nestjs-drizzle-crud follows semver:

  • Patch (3.0.x → 3.0.y). Bug fixes, no API changes.
  • Minor (3.x.0 → 3.y.0). New methods or new options, fully backwards-compatible.
  • Major (3.y.0 → 4.0.0). Breaking changes to the public API.

This site currently documents v3.2.2. The peer dependency drizzle-orm is pinned to >=0.28.0 <1.0.0.

See the Changelog for release-by-release behavior changes.

Next

You have the package installed. The next page walks through the complete five-step setup in under five minutes: schema, forRoot, service, forFeature, controller.

Quick start

On this page