Create multiple rows in table from array?
Is possible to add multiple rows at once from array with sequelize.js? This is my 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 for any advise!
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .