Many-to-Many with custom fields
Problem
Hi 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?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Many-to-Many with custom fields
Something like this is to implement "additional columns in many-to-many table" [code block] Not sure if I understood your other requests
Trust Score
9 verifications
- 1
Something like this is to implement "additional columns in many-to-many table"
Something like this is to implement "additional columns in many-to-many table"
- 2
Not sure if I understood your other requests
Not sure if I understood your other requests
Validation
Resolved in typeorm/typeorm GitHub issue #1224. Community reactions: 123 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep