Closed joaojeronimo closed 13 years ago
reply.documents.length || reply.numberReturned
Thanks amark, I also figured that but it retrieves all the documents it finds and then counts them isn't it ? I guess that's ok for less than 100 documents, but won't it be less efficient and memory hungry specially if you want to count millions of rows ?
By the way, how do I sort ?
I'd love people to jump on and help write these commands. They really aren't that hard to do - just as long as you know how MongoDB does it, it is as easy as adding a function to handle parameters and then link it to the correct javascript object.
as find() actually returns everything, it would be memory hungry. Although I'm not sure if MongoDB indexes size, either -- but at least it would be more optimized to calculate the length.
Suppose this is my find query:
db('blog.users').find(function(reply){ }, {age: 25}, {})
How do I count the number of results ? From what I see db('blog.users').find(function(reply){ }, {age: 25}, {}).count() is not possible because there is not a .count() method...
Thanks in advance.