Skip to main content

Data for NestJSs

Data access in NestJS connects services to databases through integration modules for TypeORM, Prisma, Mongoose or MikroORM. Entities or schemas model the tables, repositories or clients run queries, and transactions keep multi-step writes consistent. The database layer usually lives in providers injected into controllers' services.

Stage: Data and Security · Part of the NestJS roadmap · Last reviewed 19 November 2026

What to learn in Data

Data interview questions

Why should you avoid synchronize: true in production?

With TypeORM synchronize, schema changes are applied automatically at startup, which can drop columns or data when an entity changes. Migrations record each change as a reviewed, versioned script that can be tested and rolled back.

Why use DTOs separate from entities?

Entities describe storage and may include internal fields like password hashes. DTOs define what clients send or receive, can be validated independently, and let the database schema evolve without breaking the public API.

Where Data fits in the NestJS roadmap

Data belongs to the Data and Security stage (intermediate level). Persist and protect.

Back to the full NestJS roadmap