nnestjs-drizzle-crud
Reference

Exports

The full public API surface of nestjs-drizzle-crud, grouped by category.

Every export below is available from the package root: import { ... } from 'nestjs-drizzle-crud'.

Core

ExportKindDescription
SqlBaseCrudServiceclassThe base class your services extend. See API reference.

Module & DI tokens

ExportKindDescription
DrizzleCrudModuleclassThe Nest module. Has forRoot, forRootAsync, forFeature static methods.
DRIZZLE_DBstringDI token for the resolved Drizzle instance.
DRIZZLE_CONNECTIONstringDI token for the connection wrapper.
DRIZZLE_CRUD_CONFIGstringDI token for the normalized global config.
DrizzleConnectionclassThe internal connection wrapper. Exposed for advanced use.

Decorators

ExportKindDescription
CrudServicedecoratorAttach per-entity config to a service class. The forFeature config field still wins.

Exceptions

All exceptions extend @nestjs/common's HttpException, so Nest's default exception filter maps them to HTTP status codes automatically. They are real classes — use instanceof checks in your exception filters. See Errors for the per-method reference.

ExportHTTPDescription
EntityNotFoundException404Thrown by update, restore, massUpdate, massRestore when the row doesn't exist.
DuplicateEntityException409Thrown by create / update when a unique constraint is violated (Postgres SQLSTATE 23505).
ValidationFailedException400Throw this from your validateCreate / validateUpdate hooks to reject bad input.
BulkOperationException400Thrown by any bulk method when the transaction rolls back. Carries per-row errors.
DatabaseConnectionException500Thrown when the connection can't be established.
TransactionException500Thrown by executeSqlTransaction on transaction-level errors.

Types

ExportKind
ICrudServiceinterface — the abstract shape SqlBaseCrudService implements.
CrudFeaturetype — the input to forFeature.
DrizzleCrudConfigtype — input to forRoot / forRootAsync.
SqlCrudConfiginterface — the per-entity merged config.
SqlOperationOptionsinterface — the third argument to most methods, including search for findAll and count.
RelationConfiginterface — describes one relation in relations.
RelationsConfigtype — a record of RelationConfig.
SqlDialect'postgresql' | 'mysql'.
PrimaryKeyType'serial' | 'bigserial' | 'int' | 'bigint' | 'uuid'.
SortColumn{ column, order }.
SortOrder'asc' | 'desc'.

Re-exported Drizzle helpers

For convenience, the package re-exports the Drizzle helpers most commonly used in mapCreateDtoToEntity, custom methods, and filter construction:

import {
  and,
  asc,
  desc,
  eq,
  gt,
  gte,
  ilike,
  inArray,
  isNotNull,
  isNull,
  like,
  lt,
  lte,
  ne,
  or,
  sql,
} from 'nestjs-drizzle-crud';

All of these are pass-throughs to drizzle-orm — the package doesn't wrap or extend them.

Test utilities

ExportDescription
TestCrudFactoryClass with createMockDb, createMockTable, createMockEntity, createTestService.
BaseCrudSpecHelperA higher-level helper that builds a full service + fixtures.

See Testing for usage.

What's not exported

The following are internal to the package and should not be imported directly:

  • DrizzleCrudModule's internal connectionProviders / buildEntityConfig / normalizeConfig helpers.
  • The internal DRIZZLE_RAW_CONFIG token.

If you find yourself reaching for these, open a feature request — the public API may need a hook.

Next

On this page