typeorm是否支持SQL IN子句?我正在尝试查询一个字段匹配多个值之一的存储库。
myRepository.find({
where: {
SomeID: // IN [1, 2, 3, 4]
}
});
Run Code Online (Sandbox Code Playgroud)
您可以将QueryBuilder用于此目的:
const users = await userRepository.createQueryBuilder("user")
.where("user.id IN (:...ids)", { ids: [1, 2, 3, 4] })
.getMany();
Run Code Online (Sandbox Code Playgroud)
我只是想建议另一种方式。
const user = await this.usersRepository
.findOne(
{
where: { id: In([1, 2, 3]) }
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
685 次 |
| 最近记录: |