TypeORM ManyToMany Relationship with three entities

Viewed 18

I have the following entities:

Chat, User with a ManyToMany relationship between them.

Now I want to introduce Scopes (as a permission system), which means that Users have Scopes but they are only valid in a Chat, not globally.

I‘d image a linking table like:

user_chat_scopes (chat_id, user_id, scope_id)

How would I set this up?

Essentially when I have a Chat, I want to get the Users and their Scopes. Or if I have a User, I want to be able to get their Scope for a Chat.

Thanks in advance. I‘m on mobile so I can‘t paste my typeorm Models here efficiently but I‘m also interested in a solution the way databases are designed. I can get it done in typeorm myself then :)

0 Answers
Related