Hello, I noticed an interesting change in the functionality of mongosh versus mongo that I did not see covered in documentation. It appears mongosh handles a cursor asynchronously and I would like to know how to set it to synchronous like the original mongo shell.
Example
let curs = db.test.find()
curs.forEach(function(item){
print("1")
print("2")
})
That is a good alternative if my goal was to express some sort of output. In this case, when I am testing a more complex mongo script, it’s useful to get some feedback of what is going on so I can debug the issue. For example, in the old mongo shell. I might have something like
c.find().forEach(function(element) {
print("handling element: " + element)
print("some other information for debugging purposes")
//mutate element
})
In this case I need the log to be handled synchronously with the rest of the script. Since mongosh differs from the old mongo shell in making their stdout async, but does not provide standard scheduling/ methodologies like await, it seems that there is a rather large difference between these two shells that cannot yet be rectified with the current functionality.