summaryrefslogtreecommitdiff
path: root/shell/query.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-05-27 13:52:17 -0400
committerEliot Horowitz <eliot@10gen.com>2009-05-27 13:52:17 -0400
commitf078c67ae949889059a1765675c71820c3d801e6 (patch)
tree76bde5fc19d138501ff5e8792e80291559b56656 /shell/query.js
parentb8c3d4698621fadd61f6fabdb3a33468f7a11018 (diff)
downloadmongo-f078c67ae949889059a1765675c71820c3d801e6.tar.gz
added countReturn which takes limit and and skip into consideration
SERVER-75
Diffstat (limited to 'shell/query.js')
-rw-r--r--shell/query.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/shell/query.js b/shell/query.js
index e152c669913..2c108af42ee 100644
--- a/shell/query.js
+++ b/shell/query.js
@@ -116,6 +116,18 @@ DBQuery.prototype.count = function(){
throw "count failed: " + tojson( res );
}
+DBQuery.prototype.countReturn = function(){
+ var c = this.count();
+
+ if ( this._skip )
+ c = c - this._skip;
+
+ if ( this._limit > 0 && this._limit < c )
+ return this._limit;
+
+ return c;
+}
+
/**
* iterative count - only for testing
*/