I declare the next query:
const User = await User.findOne().and([{
"accounts.email": re.body.email
},{
status: 1
}])
What is the difference if add .exec()
at the end of the query?
CodePudding user response:
As far as the functionality is concerned adding .exec()
to async/await
query wouldn't make a difference.
But as per mongoose documentation, you "should" use .exec()
as it will provide you with better stack trace.
Check - Should You Use exec() With await?
Without
exec()
, the stack trace does not include the calling code.
With
exec()
, the stack trace includes where in your code you calledexec()