Closed leanderlee closed 12 years ago
Ohhh I got it. So apparently the callback gets called twice. as opposed to returning when complete...
How do you know when it's finished sending results?
Oh okay. there's a more: true.
This stuff needs to get documented.
the callback returns in streaming chunks of a 100 objects.
So if you have 650 objects, the callback will get called 6 times.
If there are more values the return object will have a "more" property. So you can test for that, here is an example:
mon('database.collection').find(function(p){ if(p.documents.length) { for (var i in p.documents) { // do something with the object } } if(!p.more) { //finished } });
Please let me know if that works, feel free to ask anything else.
Yep. I figured it out. Normally I wouldn't have opened an issue but it was rather mission critical.
For some reason when I do a find or any type of query that returns more than 100 records, it returns in the reply object:
"startingFrom":101 and only one object.
How do I get the previous results?