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
}
}
You could create it through
STRING
and create a customtoJSON
implementation on the instance so you can get aPOINT
you want.Data Types Instance methods
On those instance methods you can define also a
toJSON
custom method which will be automatically called when sending the object throughres.send(obj)