How can I use .find() with await ? #10930
-
Hello, const reactors = await Reactor.find(r => {
if (!r) return null
return r.channelID === oldchannel.id
}) As expected, console throws
But then my code doesn't wait the end of the research, while I'm using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You're using |
Beta Was this translation helpful? Give feedback.
You're using
find()
incorrectly. If you callfind()
with a function, Mongoose assumes the function is a callback to execute when the query completes, not a function that filters documents. You should doawait Reactor.find({ channelID: oldchannel.id })