I want to add Creator Field to all my entities for Authorization purposes . Previously i had a OneToOne relation from every entity to User entity but now i see it is adding Constraint to that tables and eventually a user is not able to create more than a single record . then i think of another Solution it was adding a ManyToOne relationship which it really is but the problem is that you have to add a corresponding field to User for every single entitiy you create . like createdPosts,createdLikes,createdComments and this is also not what i need . there is also another option to add a Creator field with a number type and leftjoin to get user every time is fetch but that add so much burden for maintenance. so is there any built-in solution for this in TypeORM to add a Field Creator to my entities with a User Type and also have the Option to eager load it during gets and Fetchs ?
class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
}
class Service extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
creator: User
}