diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-05-27 13:52:17 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-05-27 13:52:17 -0400 |
commit | f078c67ae949889059a1765675c71820c3d801e6 (patch) | |
tree | 76bde5fc19d138501ff5e8792e80291559b56656 /shell | |
parent | b8c3d4698621fadd61f6fabdb3a33468f7a11018 (diff) | |
download | mongo-f078c67ae949889059a1765675c71820c3d801e6.tar.gz |
added countReturn which takes limit and and skip into consideration
SERVER-75
Diffstat (limited to 'shell')
-rw-r--r-- | shell/query.js | 12 |
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 */ |