Created
February 25, 2015 22:38
-
-
Save Nepoxx/5b4a9671ec0fdb9246bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//First way | |
Promise.resolve(userModel.findOneAndUpdate({uid: myUserId}, updatedUserModel, { | |
upsert: true, | |
"new": false | |
}).exec()) | |
.then(function (user) { | |
... | |
}) | |
.spread(function markNotificationsAsRead(unreadNotifications) { | |
... | |
}) | |
.then(function sendResponse(unreadNotifications) { | |
... | |
}) | |
.then(null, function (err) { | |
//handle error | |
}); | |
//Second way | |
userModel.findOneAndUpdate({uid: myUserId}, updatedUserModel, { | |
upsert: true, | |
"new": false | |
}).exec() | |
.then(function (user) { | |
... | |
}) | |
.spread(function markNotificationsAsRead(unreadNotifications) { | |
... | |
}) | |
.then(function sendResponse(unreadNotifications) { | |
... | |
}) | |
.then(null, function (err) { | |
//handle error | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment