FG
🗄️ Databases

Many-to-Many with custom fields

Freshabout 8 years ago
Mar 14, 20260 views
Confidence Score78%
78%

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

Canonical Fix
High Confidence Fix
74% confidence92% success rate9 verificationsLast verified Mar 14, 2026

Solution: Many-to-Many with custom fields

Low Risk

Something like this is to implement "additional columns in many-to-many table" [code block] Not sure if I understood your other requests

74

Trust Score

9 verifications

92% success
  1. 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. 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

Worked: 9
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typeormormtypescriptquestionneeds-more-info