nestjs-database
Installation
SKILL.md
NestJS Database Standards
Priority: P0 (FOUNDATIONAL)
Selection Strategy
See references/persistence_strategy.md for database selection matrix and scaling patterns (Connection Pooling, Sharding).
Patterns
- Repository Pattern: Isolate database logic.
- TypeORM: Inject
@InjectRepository(Entity). - Prisma: Create comprehensive
PrismaService. - Abstraction: Services should call Repositories, not raw SQL queries.
Configuration (TypeORM)
- Async Loading: Always use
TypeOrmModule.forRootAsyncto load secrets fromConfigService. - Sync: Set
synchronize: falsein production; use migrations instead.