-
-
Notifications
You must be signed in to change notification settings - Fork 572
Description
Description
We are requesting the addition of official support for Drizzle ORM (TypeScript ORM) as a data provider within the @nestjsx/crud framework. Drizzle is rapidly growing in popularity within the NestJS ecosystem due to its native TypeScript approach, excellent type safety, and efficient SQL generation.
Motivation
Drizzle Adoption: Drizzle has become the preferred choice for many developers in the modern TypeScript/Postgres stack, often replacing TypeORM in new projects due to its query-builder approach and schema definition.
Boilerplate Reduction: Currently, users building NestJS applications with Drizzle must manually implement all generic CRUD logic (pagination, sorting, filtering, and relation parsing), effectively re-implementing much of the CrudService functionality provided by this library.
Community Value: Official support would significantly increase the library's relevance and adoption among the fast-growing Drizzle community.
Proposed Implementation Focus
The primary technical challenge lies in translating the standardized @nestjsx/crud query object into Drizzle's expressive SQL functions (eq, ilike, and, exists, etc.).
We believe this would primarily require creating a new provider, tentatively named CrudDrizzleService, which must handle:
Repository Abstraction: Replacing TypeORM's Repository interface with Drizzle's database instance and table object access.
Complex Filtering: Translating filter fields (e.g., $eq, $in, $ilike) from the parsed query object into Drizzle's SQL expressions.
Relation Joining: Implementing joins and filter-by-relation logic (e.g., join=contact) using Drizzle's with or exists subqueries, as direct Drizzle joins are usually used for fetching data, while filtering requires checking existence.
Pagination & Sorting: Using Drizzle's limit, offset, and dynamic asc/desc functions based on the parsed query parameters.