mongodb get count without repeating find -


when performing query in mongodb, need obtain total count of matches, along documents limited/paged subset.

i can achieve goal 2 queries, not see how 1 query. hoping there mongo feature is, in sense, equivalent sql_calc_found_rows, seems overkill have run query twice. great. thanks!

edit: here java code above.

     dbcursor cursor = collection.find(searchquery).limit(10);      system.out.println("total objects = " + cursor.count()); 

i'm not sure language you're using, can typically call count method on cursor that's result of find query , use same cursor obtain documents themselves.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -