In this video we’re going to go deep into the fundamentals of creating relationships between tables in an application which uses TypeORM.
We’ll review a target schema which we’ll represent in code. We’re going to cover all the typical table relationships you might have, like One-to-One, One-to-Many, Many-to-One, and Many-to-Many, as well as things like how to configure ON DELETE behavior, working with foreign keys, etc. Then we’ll discuss the different ways to query records with their related data!
- 00:00 - Intro and ERD
- 03:39 - Employee Entity
- 04:49 - Contact Info Entity
- 05:33 - One-to-One example
- 10:45 - On Delete CASCADE
- 11:54 - Task Entity
- 12:16 - One-to-Many / Many-to-One
- 13:28 - On Delete SET NULL
- 14:42 - Self referencing: manager/direct reports
- 17:31 - Meeting entity and Many-to-Many
- 23:05 - Various examples of inserting records and relating them to each other
- 36:00 - Querying entities with their relations using the Find API
- 39:34 - Querying entities with their relations using the Query Builder API
- 42:17 - Testing behavior of what happens when related things are deleted
- 45:12 - The Cascade option
- 47:08 - Eager and Lazy Relations
- 48:40 - Outro
#typeorm #typescript