Many-to-Many with custom fields
See original GitHub issueHi guys I was wandering if its possible to have a many-to-many relationship where I can add some custom fields to the created table. I was looking at previous issues and someone told to create the other table and use one-to-many relationship. However I’m not understanding how I would acomplish that where then I would do something like: const user = await this.userRepository.findOne(id) and get the result as a many-to-many.
Something on this lines: User: n------ n :Group
And get the output as:
{ "id": 1, "firstName": "firstname", "lastName": "lastname", "groups": [ { "id": 1, "name": "Group1" } ] }
Behind this there is the table user_group that makes this connection between User and Groups and has for example a field called isDeleted that helps me to know is this was soft deleted and not show this entry.
Could you guys help me on the right path?
Issue Analytics
- State:
- Created 6 years ago
- Comments:30 (8 by maintainers)
Top Related StackOverflow Question
Something like this is to implement “additional columns in many-to-many table”
Not sure if I understood your other requests
You can specify custom join table for ManyToMany relation