Open araggohnxd opened 1 year ago
Lets say I want to associate a user ID with my session entity, so I can easily retrieve all sessions from a user for a feature such as "logout from all devices".
Something like this:
@Entity() export class Session extends BaseEntity implements SessionEntity { @Index() @Column('bigint') expiresAt: number; @PrimaryColumn() id: string; @Column('json') data: string; @ManyToOne(() => User, (user) => user.sessions) @JoinColumn({name: 'userId'}) user: User; }
How can I make it so, whenever a new session is created, this column is populated with the associated user ID?
Lets say I want to associate a user ID with my session entity, so I can easily retrieve all sessions from a user for a feature such as "logout from all devices".
Something like this:
How can I make it so, whenever a new session is created, this column is populated with the associated user ID?