【发布时间】:2018-12-04 04:02:57
【问题描述】:
在续集中我有一个模型:
{
modelId: {
type: DataTypes.UUID ,
allowNull: false,
primaryKey: true,
defaultValue: DataTypes.UUIDV4
}
name: DataTypes.STRING(1024),
type: DataTypes.STRING,
obj: DataTypes.JSON
}
在 DB 中,我的 obj 是一个这样的数组:
[{
id: '123456',
text: 'test',
name 'xpto'
},{
id: '32554',
text: 'test2',
name 'xpte'
},{
id: '36201',
text: 'test3',
name 'xpta'
}]
我试过这些:
btp.findAll({
where: {
obj:{
[Op.contains]:[{id: req.body.id}]
}
},
attributes: ['modelId','name','type','obj']
})
但不起作用,返回此错误:
{"name": "SequelizeDatabaseError",
"parent": {
"name": "error",
"length": 128,
"severity": "ERROR",
"code": "42704",
"file": "parse_coerce.c",
"line": "1832",
"routine": "enforce_generic_type_consistency",
"sql":"....."}
所以,我需要在数据库中找到 obj 中的所有条目,id: '123456'
我的问题与此相同: https://github.com/sequelize/sequelize/issues/7349
但这对我不起作用,我需要返回所有包含...的条目 我正在使用“sequelize”:“4.28.6”和“pg-hstore”:“^2.3.2”,
有人可以帮忙吗?
【问题讨论】:
标签: node.js postgresql sequelize.js