const announcement = await this.announsRequestsRepo.findOne({
where: { id },
relations: {
owner: true,
category: true
}
})
I want to get the relations of category and more
You have two approaches: query builder
or find
method
find
const announcement = await this.announsRequestsRepo.findOne({
relations: {
owner: {
friends: true
},
category: {
subcategories: true
}
},
where: { id }
})
query builder
return await this.announsRequestsRepo
.createQueryBuilder('announcement')
.leftJoinAndSelect('announcement.owner', 'owner')
.leftJoinAndSelect('announcement.category', 'category')
and deep nest with query builder:
return await this.announsRequestsRepo
.createQueryBuilder('announcement')
.innerJoinAndSelect('announcement.owner', 'owner')
.leftJoinAndSelect('owner.friends', 'friends')
references: find method: enter link description here query builder: enter link description here