I have the following model with a column of type polygon
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('p_zones', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
points: {
type: Sequelize.GEOMETRY('POLYGON')
},
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('ZonePoints');
}
};
And when I try to seed using sequelize-cli with the command npx sequelize-cli db:seed:all
const polygon = {
type: 'Polygon',
coordinates: [
[
[10, 10],
[20, 10],
[20, 20],
[10, 20],
[10, 10],
],
],
};
const data = [{ points: polygon }];
await queryInterface.bulkInsert('p_zones', data);
I get the following error:
ERROR: Invalid value {
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 20, 10 ], [ 20, 20 ], [ 10, 20 ], [ 10, 10 ] ] ]
}
What am I doing wrong?