Reputation: 43491
I have:
this.createQueryBuilder('company')
.leftJoinAndSelect('company.companyAdmins', 'companyAdmins')
.leftJoinAndSelect('companyAdmins.user', 'user')
.where('company.id = :id', { id })
.getOne();
I want to also get all invitations
that match that company
. My invitation
model has:
@Index()
@ManyToOne(() => Company)
public company: Company;
Upvotes: 2
Views: 789
Reputation: 1881
Did you try this?
this.createQueryBuilder('company')
.leftJoinAndSelect('company.companyAdmins', 'companyAdmins')
.leftJoinAndSelect('companyAdmins.user', 'user')
.leftJoinAndSelect('company.invites', 'invites') // Adding this
.where('company.id = :id', { id })
.getOne();
Your Company entity should have:
@OneToMany(
type => Invite,
invite => invite.company,
)
invites?: Invite[];
Upvotes: 1