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

Understand how Notes persist with TypeORM entities, migrations, and seeds.

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

What this stage covers

Definition

This stage is a Notes API build slice: read the official Nest chapter, understand the matching Nest concepts, then take the quiz to lock it in.

In simpler words

Score ≥80% on the quiz below to save roadmap progress — exactly like every other topic.

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

Key Nest pieces to understand: entities, migrations, the CLI DataSource (data-source.ts), and a seed script

Supplemental tutorials: /resources → W3Schools SQL + PostgreSQL

Optional practice: rebuild the same slice for Notes in your own workspace to cement the pattern.

What a correct build includes

- [ ] synchronize: false in AppModule + data-source
- [ ] Migration reviewed; entities listed
- [ ] Seed creates users + notes

Use this as the acceptance checklist while you study the concepts and answer the quiz.

Deliverables

Definition

Deliverables are the concrete Nest files and behaviors a correct version of this stage produces.

In simpler words

Aim for the smallest vertical slice that satisfies these — not a sprawling redesign.

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…

15 questions · concept 5 · syntax 3 · practical 4 · logic 3

1. What does Notes P2 require?
Concept
2. How do you prove P2?
Syntax
3. Why synchronize false?
Practical
4. What should seed data do?
Logic
5. Why a User↔Note relation?
Concept
6. What if a migration was already applied incorrectly?
Practical
7. Can P2 be proven without notes-practice code?
Syntax
8. What does the grader look for conceptually?
Logic
9. Should notes live only in web localStorage for P2?
Concept
10. Which P2 shortcut is wrong?
Practical
11. What does this contribute to P2?
Conceptintermediate
@Entity('notes')
export class Note {
  @PrimaryGeneratedColumn('uuid')
  id: string;
  @Column()
  title: string;
}
12. Why is synchronize:false required for P2?
Syntaxadvanced
TypeOrmModule.forRoot({ url, synchronize: false });
13. What does this add for P2?
Practicalintermediate
@ManyToOne(() => User)
@JoinColumn({ name: 'author_id' })
author: User;
14. Why check findOneBy before saving in the seed?
Logicadvanced
const existing = await repo.findOneBy({ email });
if (!existing) await repo.save(user);
15. Where does this DDL belong?
Conceptintermediate
await q.query('ALTER TABLE notes ADD COLUMN author_id uuid');

Checking your session…