I will need to store a bunch of paths in a database, in TypeScript the type of these paths are sorta like:
interface Path {
waypoints: Waypoint[];
name: string;
// ... other stuff
}
interface Waypoint {
latitude: number;
longitude: number;
}
In this way, there is a one to many relationship between Path and Waypoint, In addition the waypoints have an order between them for each path.
I'm expecting in the database schema for the Path table to have a unique self incrementing ID as its primary key, and for the Waypoint table to have two columns as its primary key, the foreign key of the path it belongs to, and the index of the waypoint in the list it belongs to.
Something like this:
Path table: | ID | name | |:---|:-----| | 1 | path one| | 2 | path two|
Waypoint table: | Path ID | Index | Lat | Lng | |:--------|:------|:----|:----| | 1 | 1 | 30 | 30 | | 1 | 2 | 40 | 30 | | 2 | 1 | 70 | 50 | | 1 | 3 | 40 | 40 | | 2 | 2 | 60 | 60 |
How could I express this in TypeORM?