Superpowers
The library is small on purpose. Its strengths come from fitting into Nest without hiding Drizzle.
Full Showcase
00-showcase combines the complete first-version story: feature modules,
repositories, services, controllers, request-scoped providers, guards,
interceptors, pipes, filters, CLS transactions, @InjectTransaction(),
class-validator DTOs, optional Drizzle-Zod validation, Swagger, Express smoke
coverage, and a Fastify bootstrap file.
Inspect:
Nest-Native Database Registration
DrizzleModule.forRoot() and forRootAsync() let applications register Drizzle
clients through normal Nest modules.
Inspect:
Explicit Drizzle Queries
Schemas and queries remain Drizzle-native. There are no hidden entities or query translation layers.
Inspect:
Repository Providers Without Active Record Magic
@DrizzleRepository() marks repository classes while keeping them regular Nest
providers. DrizzleModule.forFeature() handles feature-module registration.
Inspect:
Multiple Connections
Named connections let one Nest app inject separate Drizzle clients without manual token plumbing in application code.
Inspect:
Driver-Owned Lifecycle
Applications own driver construction. DrizzleModule.forRoot() receives the
ready Drizzle client and an explicit shutdown callback for the underlying driver
handle.
Inspect:
14-better-sqlite3-driver/src/database.ts14-better-sqlite3-driver/src/app.module.ts15-postgres-driver/src/database.ts15-postgres-driver/src/app.module.ts16-mysql-driver/src/database.ts16-mysql-driver/src/app.module.ts
Transaction Decorators
@Transactional() bridges to the CLS transaction stack so workflow services can
coordinate commits and rollbacks across injected providers.
Inspect:
Transaction Escape Hatch
@InjectTransaction() gives low-level providers direct access to the active
transaction object when query composition really needs it.
Inspect:
Classic Nest DTO Validation
ValidationPipe and class-validator are the canonical Nest-native validation
path when the HTTP contract should be modeled as DTO classes.
Inspect:
08-validation-class-validator/src/customers/create-customer.dto.ts08-validation-class-validator/src/app.module.ts
Optional Schema-Derived Validation
drizzle-zod can derive request validation from Drizzle table schemas when an
application wants that style. It remains optional and app-owned rather than a
required library dependency or default Nest validation path.
Inspect:
07-validation-drizzle-zod/src/tickets/ticket.validation.ts07-validation-drizzle-zod/scripts/smoke.ts
OpenAPI Contracts
@nestjs/swagger can document DTO-backed controllers while repositories keep
Drizzle persistence explicit and type-safe behind the HTTP boundary.
Inspect:
Optional Zod Validation With OpenAPI Docs
drizzle-zod can validate incoming bodies while explicit Swagger DTOs document
the public contract. The bridge stays app-owned: Zod rejects bad input, DTOs
describe the route, and smoke tests assert the two stay aligned. Use this when
your application has already chosen schema-derived validation; otherwise, start
with DTOs and ValidationPipe.
Inspect:
Opt-In Error Mapping
mapDrizzleError() lets applications translate known database constraint
failures into Nest exceptions where persistence meets application semantics.
Inspect:
Honest Testing Utilities
DrizzleTestModule registers test clients under production tokens, while the
mock helpers stay intentionally shallow.
Inspect:
Safe Raw SQL
Drizzle's sql template remains available for advanced reporting and
vendor-specific query shapes, with values parameterized through Drizzle instead
of string concatenation.
Inspect: