Fullstack CourseLearn by building
Back to week 2

Topic

Notes API — Postgres + TypeORM milestone

Definition

Milestone P2 proves Notes persist in PostgreSQL with TypeORM entities, a reviewed migration, a seeder, and a User↔Note relation with synchronize left false.

In simpler words

Replace in-memory habits with entities, migrations, and seeds — then run the Week 2 grader.

Maps to Week 2 SQL + TypeORM. Use W3Schools SQL/PostgreSQL under /resources if you need query refreshers.

After this you can

  • Add Note + User entities and a migration with FKs/indexes
  • Keep synchronize: false in runtime and CLI DataSource
  • Seed users/notes safely and load authors without N+1 on list

How to work this milestone

Definition

A milestone is an auto-checked Notes API stage in apps/notes-practice: read the official Nest chapter, inspect the monorepo reference, implement the stage, then run the grader.

In simpler words

Literacy quiz (≥80%) still matters. The milestone command proves you can ship the week’s code.

Official tutorial order: docs/academy/fe-to-api/README.md (Week 2 — Requests, validation, TypeORM).

Official docs: Nest TypeORM technique — https://docs.nestjs.com/techniques/database

Repo reference (read-only teaching slice): apps/api/src/database/migrations, data-source.ts, ticket.entity.ts, seed.ts

Supplemental tutorials: /resources → W3Schools SQL + PostgreSQL

Implement in apps/notes-practice, then run: pnpm course:validate-milestone be-notes-p2

On green, the CLI posts POST /course/milestones/:id/complete (cookie session) so progress saves with passedVia=milestone.

Acceptance checklist

- [ ] synchronize: false in AppModule + data-source
- [ ] Migration reviewed; entities listed
- [ ] Seed creates users + notes
- [ ] pnpm course:validate-milestone be-notes-p2 is green

The grader encodes these checks; unchecked boxes mean the milestone is not done.

Deliverables

Definition

Deliverables are the concrete Nest files and behaviors this stage must produce.

In simpler words

Ship the smallest vertical slice that makes the grader green — not a redesign of the monorepo.

Note entity with author ManyToOne User

Migration creating tables/FKs; seed at least two users and notes

List uses join/relation load for author

Keep in mind

  • Never turn synchronize true “just for practice”.
  • Read generated SQL before migration:run.

Test

Check your understanding

At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥ 80% (enforced by the API) to save progress.

Checking your session…

10 questions · concept 3 · syntax 3 · practical 2 · logic 2

Concept1. Hands-on: which statement is correct about Notes P2 persistence?
Syntax2. Hands-on: which implementation matches proving P2?
Practical3. Hands-on scenario for Notes P2 persistence — what should you do?
Logic4. Hands-on: which reasoning about proving P2 holds up in production?
Concept5. Hands-on: which statement is correct about Notes P2 persistence?
Syntax6. Hands-on: which implementation matches proving P2?
Practical7. Hands-on scenario for Notes P2 persistence — what should you do?
Logic8. Hands-on: which reasoning about proving P2 holds up in production?
Concept9. Hands-on: which statement is correct about Notes P2 persistence?
Syntax10. Hands-on: which implementation matches proving P2?