Promises or async/await in mongosh?

Viewed 147

I have a mongosh script that should execute things synchronously. Can I use promises or async/await in mongosh? It seems like I can't. Is there a way to ensure things don't get executed out of order?

For example

(1) db.clients.find({}).forEach((client) => {
  db.addresses.insertMany([
    { ....
    }

(2) db.addresses.find({}).forEach...

2 gets executed by the mongosh when 1 is still looping. Any thoughts?

0 Answers
Related