NestJS
Dependency injection, request lifecycle, validation, and database integration.
TypeORM vs Sequelize vs Mongoose?
TypeORM and Sequelize are object-relational mappers for relational databases, while Mongoose models documents in MongoDB. They provide convenient data-access APIs but do not replace database knowledge. The generated queries, constraints and transaction behavior still determine correctness and performance.
Repository vs QueryBuilder vs raw SQL?
A repository exposes common operations around an entity, QueryBuilder assembles more flexible database queries, and raw SQL gives direct control over SQL text. These are levels of access rather than a ranking from bad to good. Use the simplest approach that expresses the required query clearly and efficiently.
How should a TypeORM transaction work?
A transaction groups database changes so they can commit together or roll back together. In TypeORM, the transaction callback receives a manager tied to that transaction's connection. Queries issued through an unrelated global repository may not participate, even if they appear inside the same JavaScript callback.
What are N+1, eager loading and lazy loading?
N+1 is a data-access pattern where fetching N parent records leads to roughly N more queries for related records. Eager loading fetches configured relations up front, while lazy loading waits until the relation is accessed. Both loading styles can waste work if they do not match the endpoint's real needs.
Why use migrations instead of automatic schema sync?
A migration is a versioned database change that can be reviewed and applied deliberately. Automatic schema synchronization tries to match the schema to entity definitions and may make changes without a safe production rollout plan. Migrations make data changes, compatibility and deployment order explicit.
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.