我有一個名為:UserEntity 的物體。我在這里有關系。Following/Followers.Image: 在此處輸入影像描述
const user = await this.userRepository.findOne({
where: {
id: anotherUserId || userId,
// following: { isDeleted: false }
},
select: {
following: {
id: true,
firstName: true,
lastName: true,
about: true,
organizationName: true,
profileAvatar: true,
isDeleted: true
}
},
relations: {
following: true,
}
})
我也有疑問我在哪里得到關系。我怎樣才能拿到一定的金額?(fe 帶 5 個追隨者)有可能嗎?謝謝你
uj5u.com熱心網友回復:
為此,您應該使用子查詢。
const user = await this.userRepository
.createQueryBuilder('user')
.where({ id: anotherUserId || userId })
.leftJoinAndSelect(
qb => qb
.select()
.from(YourUserRelationTable, 'r')
.where({ follower: userId })
.orderBy({ 'r.createdAt': 'DESC' })
.limit(5),
'followerRelation',
'followerRelation.id = user.id'
)
.getOne()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/518380.html
