我的模型有一个 UUID 主键,我正在尝试进行查询:
const idList = ['70ebc891-cdaf-4547-a88c-264a03c99c8d'];
MyModel.findAll({ where: {
id: {
$contained: idList
} }
})
但是这个查询不起作用,因为 idList 对于 postgres 来说是 Text[] 类型。
有没有办法在sequelize中将UUID[]强制转换为该数组,或者有其他方法来处理这个问题吗?
Postgres 错误:
ERROR: operator does not exist: uuid <@ text[] at character 137
谢谢!
最佳答案
想通了。 使用 $in 代替。
MyModel.findAll({ where: {
id: {
$in: idList
} }
})
关于postgresql - 使用 postgres 进行 Sequelize - 查找 uuid 数组中包含 uuid 的所有位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46540214/