哪个性能好?
// 1. 多次查询
const users = await Promise.all(userIds.map(id => {
return this.userRepository.findOne({
where: {
id
}
})
}))
// 2. 一次查询
const users = await this.userRepository.createQueryBuilder('user')
.where('user.id IN (:...ids)', { ids: userIds })
.getMany()