title: TypeORM - Get Matching (and related) rows form Postgres
body: <p>I am not sure if the title clearly defines the problem so I'll try explaining it here.</p>
  <p>I have 2 tables, a <code>Users</code> table and a <code>Conversations</code> table.</p>
  <p><code>Users</code> and <code>Conversations</code> have a <code>Many-to-Many</code> relationship.</p>
  <p><strong>Users Entity:</strong></p>
  <p><em>Excluding other columns</em></p>
  <pre><code>@ManyToMany(() =&gt; Conversation, (conversationEntity) =&gt; conversationEntity.participants)
      conversations: Conversation[];
  </code></pre>
  <p><strong>Conversations Entity:</strong></p>
  <p><em>Excluding other columns</em></p>
  <pre><code>@ManyToMany(() =&gt; User, userEntity =&gt; userEntity.conversations)
      @JoinTable()
      participants: User[];
  </code></pre>
  <p>Data inside the join table looks like this:</p>
  <p><a href="https://i.stack.imgur.com/FyCGm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FyCGm.png" alt="enter image description here" /></a></p>
  <p>Now, I want to get all the conversations for a specific user. But I also want to get the related rows. For example in the image above, I want to get both the rows because both rows belong to the same conversation. But since I am searching based on userId, the query skips the rows that don't match the userId.</p>
  <p>Here's the TypeORM query I am using:</p>
  <pre><code>const [results, totalCount] = await this.conversationsRepo
    .createQueryBuilder('conversations')
    .leftJoin('conversations.participants', &quot;participants&quot;)
    .andWhere('participants.id = :userId', {userId})
    .addSelect(['participants.fullName', 'participants.id'])
    .getManyAndCount();
  </code></pre>
  <p>Is there any way I can get the other participant too? I am new to TypeORM and also Postgres, so I am not sure if there's a better approach to defining the relations here. Open to suggestions!</p>
  <p>Thanks in advance!</p>