javascript - Create multiple rows in table from array? -
is possible add multiple rows @ once array sequelize.js? code:
var user = user.build({ email: req.body.email, password: req.body.password, userlevel: '3', }); user .find({ where: { email: req.body.email } }) .then(function(existinguser){ if (existinguser) { return res.redirect('/staff'); } user .save() .complete(function(err){ if (err) return next(err); res.redirect('/staff'); }); }).catch(function(err){ return next(err); });
thanks advise!
http://sequelize.readthedocs.org/en/rtd/api/model/#bulkcreaterecords-options-promisearrayinstance
user.bulkcreate([{ /* record 1 */ }, { /* record 2 */ }.. ])
Comments
Post a Comment