coll = db.getSiblingDB('test').test_coll; coll.drop(); coll.insertOne({ a: 0 }); print('before') coll.find().forEach(() => { coll.find().toArray() print('inside') }); print('after')
prints
before after inside
coll = db.getSiblingDB('test').test_coll; coll.drop(); coll.insertOne({ a: 0 }); print('before') coll.find().forEach(() => { coll.find().toArray() print('inside') }); print('after')
prints
before after inside