summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-02-27 11:16:26 -0500
committerEliot Horowitz <eliot@10gen.com>2010-02-27 11:16:26 -0500
commitdd1920617207d2742ca2ae81da1b926bb5765484 (patch)
treece08725f7310c2256d5f504532c840ef04b813ff /shell
parent11c49cb19526c02fb7411ea0efa2d608879feed1 (diff)
downloadmongo-dd1920617207d2742ca2ae81da1b926bb5765484.tar.gz
batchSize option for js and c++
Diffstat (limited to 'shell')
-rw-r--r--shell/collection.js2
-rw-r--r--shell/query.js16
2 files changed, 13 insertions, 5 deletions
diff --git a/shell/collection.js b/shell/collection.js
index 2567f6d42ea..cbb8dbd82a7 100644
--- a/shell/collection.js
+++ b/shell/collection.js
@@ -139,7 +139,7 @@ DBCollection.prototype.find = function( query , fields , limit , skip ){
}
DBCollection.prototype.findOne = function( query , fields ){
- var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields , -1 , 0 );
+ var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields , -1 , 0 , 0 );
if ( ! cursor.hasNext() )
return null;
var ret = cursor.next();
diff --git a/shell/query.js b/shell/query.js
index c2b09651e94..508fba29e2b 100644
--- a/shell/query.js
+++ b/shell/query.js
@@ -1,7 +1,7 @@
// query.js
if ( typeof DBQuery == "undefined" ){
- DBQuery = function( mongo , db , collection , ns , query , fields , limit , skip ){
+ DBQuery = function( mongo , db , collection , ns , query , fields , limit , skip , batchSize ){
this._mongo = mongo; // 0
this._db = db; // 1
@@ -12,7 +12,8 @@ if ( typeof DBQuery == "undefined" ){
this._fields = fields; // 5
this._limit = limit || 0; // 6
this._skip = skip || 0; // 7
-
+ this._batchSize = batchSize || 0;
+
this._cursor = null;
this._numReturned = 0;
this._special = false;
@@ -36,7 +37,7 @@ DBQuery.prototype.help = function(){
DBQuery.prototype.clone = function(){
var q = new DBQuery( this._mongo , this._db , this._collection , this._ns ,
this._query , this._fields ,
- this._limit , this._skip );
+ this._limit , this._skip , this._batchSize );
q._special = this._special;
return q;
}
@@ -58,7 +59,7 @@ DBQuery.prototype._checkModify = function(){
DBQuery.prototype._exec = function(){
if ( ! this._cursor ){
assert.eq( 0 , this._numReturned );
- this._cursor = this._mongo.find( this._ns , this._query , this._fields , this._limit , this._skip );
+ this._cursor = this._mongo.find( this._ns , this._query , this._fields , this._limit , this._skip , this._batchSize );
this._cursorSeen = 0;
}
return this._cursor;
@@ -70,6 +71,13 @@ DBQuery.prototype.limit = function( limit ){
return this;
}
+DBQuery.prototype.batchSize = function( batchSize ){
+ this._checkModify();
+ this._batchSize = batchSize;
+ return this;
+}
+
+
DBQuery.prototype.skip = function( skip ){
this._checkModify();
this._skip = skip;