• OneToMany
    • https://yangeok.github.io/orm/2020/12/14/typeorm-decorators.html
  • ManyToMany
    • https://jonyo.tistory.com/150

    • 연관되어 있는 배열 가져올 때 원하는 컬럼만 가져오기

    • https://ganzicoder.tistory.com/160

    • 기존에 컬럼 전부 방법

      const group = await this.groupRepository.findOne(groupId, { relations: ["users"] });
      
      =
      
      const group = await this.groupRepository
            .createQueryBuilder("group")
            .leftJoinAndSelect("group.users", "user")
            .where("group.groupId = :id", { id: groupId })
            .getOne();
      
    • 원하는 컬럼만 가져오는 방법

      const group = await this.groupRepository
            .createQueryBuilder("group")
            .leftJoin("group.users", "user")
            .select(["group.groupCode", "user.profileImage", "user.userNickname", "user.userEmail"])
            .where("group.groupId = :id", { id: groupId })
            .getOne();