Hi,
How this Q can be used get promises in mongoose async function like:
User.findOne({ Email: userEmail }, function (err, user) {
if (err) {
resultMessage = 'No user found for username: ' + userEmail;
reject([resultMessage,0]);
} else {
resolve([user,1]);
}
});
The findOne method gets 2 arguments like err and user, where as in examples everywhere there is no second argument.
So how can I resolve promise separately for error and success conditions?
Hi,
How this Q can be used get promises in mongoose async function like:
User.findOne({ Email: userEmail }, function (err, user) {
if (err) {
resultMessage = 'No user found for username: ' + userEmail;
reject([resultMessage,0]);
} else {
resolve([user,1]);
}
});
The findOne method gets 2 arguments like err and user, where as in examples everywhere there is no second argument.
So how can I resolve promise separately for error and success conditions?