我有一个地址模型(Sequelize)声明如下:
var address = sequelize.define("address", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
coordinates: {
type: DataTypes.GEOMETRY,
allowNull: false
},
/* ... */
});
现在我试图检索距离25Km的所有地址:
const distance = models.sequelize.fn('ST_Distance', models.sequelize.col('coordinates'), city.coordinates);
return models.address.findAll({
where: models.sequelize.where(distance, { $lte: 25000 })
});
转换为以下查询:
SELECT * FROM "addresses" AS "address" WHERE
ST_Distance("coordinates", "type" = \'Point\' AND "coordinates" IN (41.544031, -8.426646))
<= \'25000\';
抛出错误:列&#34;键入&#34;不存在。
sequelize:3.23.3, postgres:9.4.12
我做错了什么?