stijnsanders / TMongoWire

Delphi MongoDB driver
MIT License
102 stars 37 forks source link

Number To Return #37

Closed scaleman114 closed 7 years ago

scaleman114 commented 7 years ago

Would it be possible to show an example with the NumberToReturn property? I don't seem to be able to get it to work. When I set WireQuery.NumberToReturn := 2; It seems to make no difference.

stijnsanders commented 7 years ago

This may have changed since I created the NumberToReturn property: https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#op-query Apparently, if you set the property to a negative value, the cursor will be closed after that number. If you set it to a positive number, the first response to the query will be limited to this number of documents. Depending on the average size of documents this may speed up getting this first set of documents, but the cursor will stay open and TMongoWireQuery.Next will just perform as expected and pull in more documents after that, if there are more available. Does that answer your question?

scaleman114 commented 7 years ago

Yes that answers my question. Many thanks for your help.