我在搜索时遇到了问题,包括按某个点的距离排序。这是我的代码以及我要执行的操作。感谢帮助
const Sequelize = require('sequelize');
var Flat = db.define('flat', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
}
});
var FlatAddress = db.define('flat_address', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
flat_id: {
type: Sequelize.INTEGER,
foreignKey:true,
allowNull:false,
references: {
model:'flats',
key: 'id'
}
},
city: {
type: Sequelize.STRING(50) //post_town
},
location: {
type: Sequelize.GEOMETRY('POINT')
}
});
Flat.hasOne(FlatAddress, { as: 'Address', foreignKey: 'flat_id', otherKey: 'id', onDelete: 'cascade' });
FlatAddress.belongsTo(Flat, { foreignKey: 'id', otherKey: 'flat_id', onDelete: 'cascade' });
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情 …