Reputation: 21
How can I make a relation between two tables, where the first table is called users
and the second is called cars
?
A user
can have from 0 to infinite cars
, and a car
can only have one user
. I need to make this relation passing ids from cars
to users
.
Using NodeJS TypeORM and MySQL.
Upvotes: 0
Views: 572
Reputation: 182
you need to use Many-to-one / one-to-many relations . you can check this example and get some idea. https://typeorm.io/#/many-to-one-one-to-many-relations
Upvotes: 1