我有一个模型的属性,类型为GEOMETRY(' polygon '),用数据库mySQL继续。
此类型的属性从BLOB类型开始保存在DB中。
我想在此模型上执行sequelize隐式findOne操作,在where子句中指定此几何类型属性。
当我尝试做同样的事情时,它给出了一个没有任何错误陈述的错误,而如果我在where子句中指定了表的任何其他字段,它会给出结果。
我的代码示例如下:
用户模型:
module.exports = {
attributes: {
geometry: {
type: Sequelize.GEOMETRY('POLYGON')
}
}
}
用户控制器:
find: function(req, res) {
var point = {
type: 'Polygon',
coordinates: [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
};
User.findOne({
where: {
"geometry": point
}
}).then(function(polygonData) {
return res.ok(polygonData);
}).catch(function(exception) {
return res.badRequest(exception);
});
}
当我试图检索它时,它给我错误对象:
{
"error@context":{
}
}
我已经提到了一些已经存在的问题:
Mysql query check the blob column type in where clause
Using BLOB in where clause in MySQL
但仍然徒劳无功。
如果有人可以帮我这么做,那么我可以在where子句中指定blob类型,这将是很棒的。 我不喜欢通过原始查询来做这件事,但如果没有别的办法,那么无论如何都要这样做。
需要更多信息,可以参考here。