August 2016
Intermediate to advanced
376 pages
6h 33m
English
The main difference between both database mappers is that Sequelize uses promises and Mongoose does not. Promises are easy to handle with asynchronous events. To be more clear, let's see the following code to compare both middlewares:
passport.js file from the previous chapter: User.findOne({ 'local.email' : email }, function(err, user) { // if errors if (err) return done(err); // check email if (user) { return done(null, false, req.flash('signupMessage', 'Wohh! the email is already taken.')); } else { // create the user var newUser = new User(); // Get user name from req.body newUser.local.name = req.body.name; newUser.local.email = email; newUser.local.password ...Read now
Unlock full access