moviesCollection.find(queryFilter).iterator().forEachRemaining(results::add); vs moviesCollection.find(queryFilter).into(result);)

Approach 1:

Approach 2:

So far, you have completely neglected to point out why you use approach 1 sometimes and approach 2 at other times.

1 Like

I´d also be interested in if there is any difference in these two approaches?

I don’t know this for sure, but to me it seems like Approach 1 is used when there is a sort and Approach 2 when there is no sort. So I assumed that Approach 2 has some rare cases where it manipulates the order of items, while Approach 1 keeps the order 100% of the time.
But as said in the beginning, I’m not sure if this is the case and I couldn’t find anything specific about this in the docs.