Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

count takes skip/limit

  • Loading branch information...
commit db4569cc56dec17e2630a18c68baee254da7c597 1 parent 876dae7
@erh erh authored
Showing with 10 additions and 3 deletions.
  1. +9 −2 client/dbclient.cpp
  2. +1 −1  client/dbclient.h
View
11 client/dbclient.cpp
@@ -222,9 +222,16 @@ namespace mongo {
return runCommand(dbname, b.done(), *info);
}
- unsigned long long DBClientWithCommands::count(const string &_ns, const BSONObj& query, int options) {
+ unsigned long long DBClientWithCommands::count(const string &_ns, const BSONObj& query, int options, int limit, int skip ) {
NamespaceString ns(_ns);
- BSONObj cmd = BSON( "count" << ns.coll << "query" << query );
+ BSONObjBuilder b;
+ b.append( "count" , ns.coll );
+ b.append( "query" , query );
+ if ( limit )
+ b.append( "limit" , limit );
+ if ( skip )
+ b.append( "skip" , skip );
+ BSONObj cmd = b.obj();
BSONObj res;
if( !runCommand(ns.db.c_str(), cmd, res, options) )
uasserted(11010,string("count fails:") + res.toString());
View
2  client/dbclient.h
@@ -412,7 +412,7 @@ namespace mongo {
/** count number of objects in collection ns that match the query criteria specified
throws UserAssertion if database returns an error
*/
- unsigned long long count(const string &ns, const BSONObj& query = BSONObj(), int options=0 );
+ unsigned long long count(const string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 );
string createPasswordDigest( const string &username , const string &clearTextPassword );
Please sign in to comment.
Something went wrong with that request. Please try again.