Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to add custom metadata to the session table? #34

Open
araggohnxd opened this issue Aug 24, 2023 · 0 comments
Open

Is there a way to add custom metadata to the session table? #34

araggohnxd opened this issue Aug 24, 2023 · 0 comments

Comments

@araggohnxd
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant