Currently leveraging TypeORM in tandem with MySQL, my database comprises of two main Entities, namely User and Project:
@Entity()
class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({})
name: string;
}
@Entity()
class Project {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({})
name: string;
}
In the near future, I aim to introduce a third Entity called Invitation. Each invitation is uniquely identified by the userId and projectId pair. Although a user can receive invites for multiple projects, they should only have one invite per project. Additionally, I intend to record the user responsible for sending out the invitation.
@Entity()
class Invitation {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({})
userID: string;
@Column({})
invitedById: string;
@Column({})
projectID: string;
@Column({})
otherInformations: string;
}
I am seeking advice on how to properly establish these relationships using TypeORM's Relation decorators. Any guidance would be greatly appreciated as I am relatively new to the realm of ORM development.
Wishing you all an enjoyable end to your weekend.