CRUD & DB Modelling with NestJS, Drizzle ORM & PostgreSQL
Details
What You Will Build
A fully containerized, relational REST API that manages departments, employees, employee profiles, and projects — wired together through all three relationship cardinalities found in real-world business data. By the end of the session, you will have a running API, a migrated PostgreSQL database, seeded demo data, and a test request collection covering every endpoint.
Learning Outcomes
By the end of this workshop, you will be able to:
- Design a normalized relational schema with 1:N, 1:1, and N:N relationships in Drizzle ORM.
- Choose the correct cascade policy for each FK and explain the tradeoff.
- Write type-safe relational queries that avoid N+1 without exposing ORM internals to API clients.
- Design REST routes that follow a consistent, idiomatic convention for related resources.
- Validate incoming data at the HTTP boundary with zod and map DB-level constraint violations to appropriate HTTP status codes.
- Implement paginated, sortable, filterable list endpoints with a standard response envelope.
- Manage the full migration and seed lifecycle with Drizzle Kit.
Related topics
nodeJS
PostgreSQL
Typescript
Software Development
Docker
