Sunday, 22 December 2019

js break from foreach (mongoshell)

for normal js, if you want to break from forEach:

https://stackoverflow.com/questions/6260756/how-to-stop-javascript-foreach


for mongoshell.  the forEach function from cursor is a build in function, it doesn't support "some"

so if you want to break with "some" , you can only do that with normal js array. e.g. in your search result, there is an array in a field. then you can use it to this array field.

No comments:

Post a comment