I was going through the mongoose docs when I Stumbled upon the line saying
Mongoose queries are not promises. They have a .then() function for co and async/await as a convenience. If you need a fully-fledged promise, use the .exec() function.
With this example
var query = Band.findOne({name: "Guns N' Roses"});
assert.ok(!(query instanceof Promise));
// A query is not a fully-fledged promise, but it does have a `.then()`.
query.then(function (doc) {
// use doc
});
// `.exec()` gives you a fully-fledged promise
var promise = query.exec();
assert.ok(promise instanceof Promise);
promise.then(function (doc) {
// use doc
});
Now, I didn't get what they meant when they said fully-fledge promise, like for me .then()
should be a promoise and then it also allows async and await.
So can someone please explain me what does fully-fledge promise mean?
Reference link: https://mongoosejs.com/docs/promises.html#queries-are-not-promises