AgentStack
SKILL verified MIT Self-run

Nestjs Database

skill-dkmqflx-nestjs-best-practices-plugin-nestjs-database · by dkmqflx

NestJS database and ORM best practices (TypeORM, Prisma, Mongoose). Use when integrating a database in NestJS — repositories, entities, migrations, transactions, or query performance. Triggers on TypeOrmModule, @InjectRepository, PrismaService, @Entity, migrations, or N+1 queries.

No reviews yet
0 installs
0 views
view→install

Install

$ agentstack add skill-dkmqflx-nestjs-best-practices-plugin-nestjs-database

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Nestjs Database? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

NestJS Database & ORM

Best-practices reference for integrating a database into NestJS through TypeORM, Prisma, or Mongoose. Covers async module configuration, repository injection, schema lifecycle (migrations vs synchronize), transactions, relation loading, projection, DTO mapping, and indexing/pagination. Examples favor TypeORM with Prisma notes where the idiom differs.

When to Apply

  • Wiring TypeOrmModule/MongooseModule/PrismaModule with ConfigService
  • Injecting repositories or model services into providers
  • Choosing between synchronize and migrations for schema changes
  • Writing multi-step writes that must be atomic (transactions)
  • Loading relations efficiently (avoiding N+1 queries)
  • Selecting only needed columns / not over-fetching
  • Returning data from controllers without leaking ORM entities
  • Indexing queried columns and paginating large result sets

Rules

  • async-module-config - configure the data layer with forRootAsync + ConfigService; never hardcode credentials
  • repository-pattern - inject repositories/services into providers; keep DB access out of controllers
  • migrations-not-synchronize - set synchronize: false in production and manage schema with migrations
  • transactions-for-multi-write - wrap multi-step writes in a transaction (QueryRunner / dataSource.transaction / prisma.$transaction)
  • avoid-n-plus-one - load relations explicitly (relations/leftJoin/include); never query inside a loop
  • select-needed-columns - project specific fields; avoid SELECT * and over-fetching
  • separate-entities-from-dtos - map ORM entities to response DTOs; don't expose persistence models directly
  • index-and-pagination - index queried columns and paginate large results with take/skip

How to Use

Read individual rule files in rules/ for the rationale plus incorrect/correct examples. Each rule is self-contained; apply the ones relevant to the change you are making. Default to TypeORM idioms; Prisma/Mongoose equivalents are noted inline where they differ.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.