If we request certain amount of values from a cursor the mongo db server can
return less than requested. So, if we provide -100000 then mongodb may
return 97899 and close the cursor.
Instead of relying on negative values this implementation will use only
positive numbers and will close the cursor itself as soon as the driver
receives enough results.
It fixes the issue #24 from github.
I have a reader monad with app configuration that I would like to make an instance of HasMongoContext and then need the MongoContext constructor to add a MongoContext to my own reader monad.
`Database.MongoDB.Query.next` and `nextBatch` prefetch a promise of the next
batch of documents from the server whenever the current batch has been
exhausted. The following call to `next` or `nextBatch` fulfills that promise
(thereby turning it into a concrete batch of documents) and then returns one or
more documents in the batch.
The old behavior was to raise an exception if an empty batch with a nonzero
cursor ID was encountered. This is normal when using tailable cursors, so a
change was required.
Now, `Nothing` is returned with the still-live cursor ID, instead of raising
the exception. Also, prefetched empty batches with nonzero cursor IDs are
refetched once per call to avoid stale data.
This new prefetching behavior does not affect the performance of `next`, except
when calling it repeatedly on a tailable cursor with no new data. In those
(generally avoidable) cases, each call to `next` results in two server calls
instead of one.
the fields of a Database.MongoDB.Internal.Protocol.Query were not filled in by RecordWildcard on line 411 of Database/MongoDB/Query.hs because the record fields were not in scope