Since the new API has the method then, when returning a model from an async function, node will try to run that then function without a query.
eg:
const test = async () => {
let model = await Model.findById([id]);
// return model
return model;
};
const testagain = async () => {
// await test
await test (); // this will fail, throwing "Expected `query` to be object or undefined, got function"
};
Since the new API has the method
then
, when returning a model from an async function, node will try to run that then function without a query.eg: