You can find the return type of specific operations You can also read more about promises in Mongoose.
are not promises. They have a function for co and async/await as a convenience. If you need a fully-fledged promise, use the .exec()
function.
There are two alternatives for using with queries:
await Band.findOne().exec();
As far as functionality is concerned, these two are equivalent. However, we recommend using .exec()
because that gives you better stack traces.
Want to learn how to check whether your favorite npm modules work with async/await without cobbling together contradictory answers from Google and Stack Overflow? Chapter 4 of Mastering Async/Await explains the basic principles for determining whether frameworks like React and Mongoose support async/await.