Registry / database / nestjs-drizzle

nestjs-drizzle

JSON →
library1.1.6jsnpmunverified

NestJS Drizzle ORM Helper Module v1.1.6. Provides a seamless integration of Drizzle ORM into NestJS applications with support for multiple databases: PostgreSQL (including Neon, Vercel, Supabase), MySQL (including PlanetScale), SQLite, Turso/LibSQL. Follows NestJS module conventions with DrizzleModule.forRoot() and per-database driver imports. Ships TypeScript types. Release cadence is irregular; stable but not widely adopted. Differentiator: official Drizzle NestJS integration alternatives exist, but this package simplifies configuration with driver-specific modules.

npm install nestjs-drizzle
INSTALL
IMPORT
SIG · NESTJS-DRIZZLE
N
nestjs-drizzle
databasejavascriptv1.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DrizzleModule
✓ import { DrizzleModule } from 'nestjs-drizzle/postgres'
✗ import { DrizzleModule } from 'nestjs-drizzle'
You must import from the driver-specific subpath (e.g., 'nestjs-drizzle/postgres') not the root package.
DrizzleModule
✓ import { DrizzleModule } from 'nestjs-drizzle/mysql'
For MySQL and PlanetScale.
DrizzleModule
✓ import { DrizzleModule } from 'nestjs-drizzle/sqlite'
For SQLite and Turso.
module options
✓ DrizzleModule.forRoot({ schema, ... })
✗ DrizzleModule.register({ ... })
Use forRoot() not register().

Basic NestJS module setup with DrizzleModule.forRoot() and injection of Drizzle database instance.

// app.module.ts import { Module } from '@nestjs/common'; import { DrizzleModule } from 'nestjs-drizzle/postgres'; import * as schema from './drizzle/schema'; @Module({ imports: [ DrizzleModule.forRoot({ schema, connectionString: process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:5432/db', }), ], }) export class AppModule {} // service.ts import { Injectable } from '@nestjs/common'; import { InjectDrizzle } from 'nestjs-drizzle/postgres'; import { NodePgDatabase } from 'drizzle-orm/node-postgres'; import * as schema from './drizzle/schema'; @Injectable() export class UsersService { constructor(@InjectDrizzle() private readonly db: NodePgDatabase<typeof schema>) {} async findUser(id: string) { return this.db.query.users.findFirst({ where: (users, { eq }) => eq(users.id, id) }); } }
Debug
Known issues
breakingMultiple DrizzleModule.forRoot() calls will throw: 'Drizzle module has already been initialized'
fix
Ensure only one forRoot() call in your app module. Use forFeature() for additional schemas if needed.
affects: >=1.0.0
gotchaYou must manually install database drivers (pg, mysql2, etc.) - they are not included as dependencies.
fix
Install the appropriate driver package for your database (see README).
affects: >=1.0.0
gotchaImport from wrong subpath (e.g., 'nestjs-drizzle' without driver) will result in 'Cannot find module' error.
fix
Always import from the specific driver path like 'nestjs-drizzle/postgres' or 'nestjs-drizzle/mysql'.
affects: >=1.0.0
deprecatedOld import style 'nestjs-drizzle' (without driver) was deprecated in v1.1.0
fix
Update imports to use driver-specific subpaths.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'nestjs-drizzle' or its corresponding type declarations.
Wrong import path - must include driver subpath.
fix
Use import { DrizzleModule } from 'nestjs-drizzle/postgres' (or mysql, sqlite).
The 'DrizzleModule' class does not have a static method 'register'.
Using incorrect method name.
fix
Replace DrizzleModule.register() with DrizzleModule.forRoot().
Drizzle module has already been initialized
Calling forRoot() more than once.
fix
Ensure only one call to DrizzleModule.forRoot() in your application.
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
drizzle-ormrequiredCore ORM library required for all database operations
pgoptionalRequired for PostgreSQL driver
@neondatabase/serverlessoptionalRequired for Neon serverless driver
@vercel/postgresoptionalRequired for Vercel Postgres driver
mysql2optionalRequired for MySQL driver
@planetscale/databaseoptionalRequired for PlanetScale driver
better-sqlite3optionalRequired for SQLite driver
@libsql/clientoptionalRequired for Turso/LibSQL driver
Agent activity
11 hits · last 30 days
node
10
Resources
nestjs-drizzle — npm install nestjs-drizzle · libregistry