title: removing a single row in a manytomany table with TypeORM / NestJS
body: <p>I have a <code>nestJS</code> project with two entities, a user entity and a chatroom entity, there can be multiple users in a chatroom and users can be in multiple chatrooms, here's the chatroom entity :</p>
  <pre><code>@Entity()
  export class ChatRoom{
      @PrimaryGeneratedColumn()
      id: number;
  
      @Column()
      name: string;
  
      @Column('int', {array: true, default: []})
      public adminId: number[];
  
      @Column()
      ownerId: number;
  
      @ManyToMany(() =&gt; User, { cascade: true, onUpdate:'CASCADE' })
      @JoinTable()
      users: User[];
  }
  </code></pre>
  <p>and user entity :</p>
  <pre><code>@Entity()
  export class User {
    @PrimaryColumn()
    public id: number;
   
    @Column({nullable: true})
    public username: string;
  
    @Column()
    public log: string;
  
    @Column({default: 0})
    public rank: number;
  
    @Column('int', {array: true, default: []})
    public blocked: number[];
  
    @ManyToMany(() =&gt; ChatRoom, room =&gt; room.users)
    rooms: ChatRoom[];
  }
  </code></pre>
  <p>Right now with <code>querybuilder</code> I managed to get the list of users in a chatroom and to get the list of chatrooms a user has joined, however I would like to know how to delete a single relationship, if a user wants to leave a room, how do i remove the matching row without removing the user entity or the chatroom entity itself ?</p>
  <p>This is the initial chatroom service code I wrote in order to remove a specific user from a chatroom's users list :</p>
  <pre><code>async removeUserFromRoom(user: User, roomid: number)
      {
          const room = await this.chatRepo.findOne(roomid);
          if (room)
          {
              room.users = room.users.filter(user =&gt; {
                  user.id !== user.id
              })
              await this.chatRepo.save(room);
          }
          else
              throw new HttpException('Room not found', HttpStatus.NOT_FOUND);
      }
  </code></pre>
  <p>Although this solution will not work because the room entity does not have an array of users defined, do I need to run a query in order to remove the user from the chatroom ? or is there a way to handle this in <code>TypeORM</code> ? if it seems like I misunderstood something please let me know as I am relatively new to databases and queries.</p>