Mongoose's documentations affirms that method save returns a promise. I would like to save a user model in my database using this method. I do this like that :
save (user) {
user.save((err, user) => {
if (err) {
return handleError(err);
} else {
console.log('The user ' + user.screenName + ' has been added.');
}
this.db.close();
});
}
Note that user param is :
mongoose.model('User', this.userSchema);
I don't understand why the console.log below returns false :
console.log((userRepository.save(user) instanceof Promise));
And of course when I try to then() the promise I doesn't work.
Am I missing something ? I also tried to return the user.save(...) but it still did not work.
Thanks for reading my message and have nice day!