diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-01-25 02:00:30 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-01-25 02:02:37 -0500 |
commit | a7eb7f2c47f247f6a9632ecd491536c93aa7ef3a (patch) | |
tree | d57cb20bb5e4a9506c2c450ba8b0c0bd6f3f7eac /shell | |
parent | 34e9ef62fbe4f3ba285efa2e37f5fc33e6462c23 (diff) | |
download | mongo-a7eb7f2c47f247f6a9632ecd491536c93aa7ef3a.tar.gz |
shell can pass query options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/collection.js | 3 | ||||
-rw-r--r-- | shell/mongo.js | 2 | ||||
-rw-r--r-- | shell/mongo_vstudio.cpp | 17 | ||||
-rw-r--r-- | shell/query.js | 12 |
4 files changed, 24 insertions, 10 deletions
diff --git a/shell/collection.js b/shell/collection.js index 01180cdf0ef..8d4d4c703f1 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -146,7 +146,8 @@ 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 , 0 ); + var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields , + -1 /* limit */ , 0 /* skip*/, 0 /* batchSize */ , 0 /* options */ ); if ( ! cursor.hasNext() ) return null; var ret = cursor.next(); diff --git a/shell/mongo.js b/shell/mongo.js index 1601706f3e4..e129784bf66 100644 --- a/shell/mongo.js +++ b/shell/mongo.js @@ -12,7 +12,7 @@ if ( ! Mongo.prototype ){ } if ( ! Mongo.prototype.find ) - Mongo.prototype.find = function( ns , query , fields , limit , skip ){ throw "find not implemented"; } + Mongo.prototype.find = function( ns , query , fields , limit , skip , batchSize , options ){ throw "find not implemented"; } if ( ! Mongo.prototype.insert ) Mongo.prototype.insert = function( ns , obj ){ throw "insert not implemented"; } if ( ! Mongo.prototype.remove ) diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp index 96bedfd3e69..8f985a50437 100644 --- a/shell/mongo_vstudio.cpp +++ b/shell/mongo_vstudio.cpp @@ -2276,7 +2276,7 @@ const StringData _jscode_raw_mongo = "}\n" "\n" "if ( ! Mongo.prototype.find )\n" -"Mongo.prototype.find = function( ns , query , fields , limit , skip ){ throw \"find not implemented\"; }\n" +"Mongo.prototype.find = function( ns , query , fields , limit , skip , batchSize , options ){ throw \"find not implemented\"; }\n" "if ( ! Mongo.prototype.insert )\n" "Mongo.prototype.insert = function( ns , obj ){ throw \"insert not implemented\"; }\n" "if ( ! Mongo.prototype.remove )\n" @@ -2458,7 +2458,7 @@ const StringData _jscode_raw_query = "// query.js\n" "\n" "if ( typeof DBQuery == \"undefined\" ){\n" -"DBQuery = function( mongo , db , collection , ns , query , fields , limit , skip , batchSize ){\n" +"DBQuery = function( mongo , db , collection , ns , query , fields , limit , skip , batchSize , options ){\n" "\n" "this._mongo = mongo; // 0\n" "this._db = db; // 1\n" @@ -2470,6 +2470,7 @@ const StringData _jscode_raw_query = "this._limit = limit || 0; // 6\n" "this._skip = skip || 0; // 7\n" "this._batchSize = batchSize || 0;\n" +"this._options = options || 0;\n" "\n" "this._cursor = null;\n" "this._numReturned = 0;\n" @@ -2500,7 +2501,7 @@ const StringData _jscode_raw_query = "DBQuery.prototype.clone = function(){\n" "var q = new DBQuery( this._mongo , this._db , this._collection , this._ns ,\n" "this._query , this._fields ,\n" -"this._limit , this._skip , this._batchSize );\n" +"this._limit , this._skip , this._batchSize , this._options );\n" "q._special = this._special;\n" "return q;\n" "}\n" @@ -2522,7 +2523,7 @@ const StringData _jscode_raw_query = "DBQuery.prototype._exec = function(){\n" "if ( ! this._cursor ){\n" "assert.eq( 0 , this._numReturned );\n" -"this._cursor = this._mongo.find( this._ns , this._query , this._fields , this._limit , this._skip , this._batchSize );\n" +"this._cursor = this._mongo.find( this._ns , this._query , this._fields , this._limit , this._skip , this._batchSize , this._options );\n" "this._cursorSeen = 0;\n" "}\n" "return this._cursor;\n" @@ -2541,6 +2542,11 @@ const StringData _jscode_raw_query = "}\n" "\n" "\n" +"DBQuery.prototype.addOption = function( option ){\n" +"this._options |= option;\n" +"return this;\n" +"}\n" +"\n" "DBQuery.prototype.skip = function( skip ){\n" "this._checkModify();\n" "this._skip = skip;\n" @@ -2919,7 +2925,8 @@ const StringData _jscode_raw_collection = "}\n" "\n" "DBCollection.prototype.findOne = function( query , fields ){\n" -"var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields , -1 , 0 , 0 );\n" +"var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields ,\n" +"-1 /* limit */ , 0 /* skip*/, 0 /* batchSize */ , 0 /* options */ );\n" "if ( ! cursor.hasNext() )\n" "return null;\n" "var ret = cursor.next();\n" diff --git a/shell/query.js b/shell/query.js index 45dd8862b49..4044894a070 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 , batchSize ){ + DBQuery = function( mongo , db , collection , ns , query , fields , limit , skip , batchSize , options ){ this._mongo = mongo; // 0 this._db = db; // 1 @@ -13,6 +13,7 @@ if ( typeof DBQuery == "undefined" ){ this._limit = limit || 0; // 6 this._skip = skip || 0; // 7 this._batchSize = batchSize || 0; + this._options = options || 0; this._cursor = null; this._numReturned = 0; @@ -43,7 +44,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._batchSize ); + this._limit , this._skip , this._batchSize , this._options ); q._special = this._special; return q; } @@ -65,7 +66,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._batchSize ); + this._cursor = this._mongo.find( this._ns , this._query , this._fields , this._limit , this._skip , this._batchSize , this._options ); this._cursorSeen = 0; } return this._cursor; @@ -84,6 +85,11 @@ DBQuery.prototype.batchSize = function( batchSize ){ } +DBQuery.prototype.addOption = function( option ){ + this._options |= option; + return this; +} + DBQuery.prototype.skip = function( skip ){ this._checkModify(); this._skip = skip; |