I'm using sequelize ORM to connect to a MYSQL database - how would I define a geo POINT in the table/object model? Since sequelize doesn't have a POINT data type can I just pass in a string that represents a MYSQL type?
db.define(modelName, {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false
},
location:{
type:'POINT' //how would I define this??
},
createdBy: {
type: Sequelize.INTEGER,
references: {
model: 'User',
key: 'id'
}
},
photoId: {
type: Sequelize.UUID
},
caption: {
type: Sequelize.STRING
}
}
Since 3.4.0 Sequelize support geometry for postgres. Based on commit messages, MySQL is also supported.
You can add new attribute like this:
point: {
type: Sequelize.GEOMETRY('POINT'),
},
The supported types for MySQL are:
var SUPPORTED_GEOMETRY_TYPES = ['POINT', 'LINESTRING', 'POLYGON'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With