express - Save array of objects in Postgresql using Sequalize.js -
i have comething this
[{ "id":"3", "clientname":"john doe", "address":"street, 15", "latitude":"50.1212", "longitude":"30.1111", "timefrom":"2017-04-05t14:48:00.000z", "timeto":"2017-04-05t15:48:00.000z", "comments":"call before delivery" }]
this part of model:
order = sequelize.define('order', { latitude: { type: datatypes.float, allownull: false, defaultvalue: null, validate: { min: -90, max: 90 } }, longitude: { type: datatypes.float, allownull: false, defaultvalue: null, validate: { min: -180, max: 180 } }, { classmethods: { associate: function (models) { order.belongsto(models.user); } } }); return order;
how write array of object via sequalize.js? if i'm trying write object, it's pass fine, [{},{}] got troubles
you'll want start here .bulkcreate() - http://docs.sequelizejs.com/en/v3/docs/instances/#working-in-bulk-creating-updating-and-destroying-multiple-rows-at-once
it can take array of objects , write them long keys in object match column names.
Comments
Post a Comment