You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A module to integrate popular ORMs (TypeORM, Prisma, Drizzle, etc.) with NexusDI, providing injectable repositories/clients, lifecycle management, and a familiar, ergonomic API for developers.
Motivation
Dependency injection for repositories/clients: Make it easy to inject and mock repositories or database clients in services.
Centralized config and connection management: Manage database connections and ORM configuration in one place.
Support for multiple ORMs and databases: Allow users to choose their preferred ORM and database backend.
Ergonomic API: Use decorators like @InjectRepository to provide runtime metadata for entity injection.
Proposed Features
Register ORM connections via config or async config (e.g., in container.json)
Inject repositories/clients into services using an @InjectRepository decorator (for TypeORM/Drizzle) or direct injection (for Prisma)
Support for transactions, migrations, and connection pooling
Optional: adapters for multiple ORMs (TypeORM, Prisma, Drizzle, MikroORM, etc.)
Support for custom repositories and query runners
Easy mocking/overriding of repositories for testing
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
A module to integrate popular ORMs (TypeORM, Prisma, Drizzle, etc.) with NexusDI, providing injectable repositories/clients, lifecycle management, and a familiar, ergonomic API for developers.
Motivation
@InjectRepositoryto provide runtime metadata for entity injection.Proposed Features
container.json)@InjectRepositorydecorator (for TypeORM/Drizzle) or direct injection (for Prisma)Example Workflow
Configure the ORM module in
container.json:{ "database": { "orm": "typeorm", "type": "postgres", "url": "postgres://user:pass@localhost:5432/mydb", "entities": ["src/entities/*.ts"], "synchronize": true } }Register the ORM module:
Inject repositories into services:
For Prisma or other client-based ORMs:
Open Questions
API Sketch
Call for Feedback
Beta Was this translation helpful? Give feedback.
All reactions