SERVER-2031: setSlaveOk at each level in shell
This commit is contained in:
@@ -1475,7 +1475,7 @@ const StringData _jscode_raw_utils =
|
||||
"print(\"\\tan error, even if the command succeeds.\");\n"
|
||||
"print(\"\\tsee also http://<mongod_host>:28017/_replSet for additional diagnostic info\");\n"
|
||||
"}\n"
|
||||
"rs.slaveOk = function () { return db.getMongo().setSlaveOk(); }\n"
|
||||
"rs.slaveOk = function (value) { return db.getMongo().setSlaveOk(value); }\n"
|
||||
"rs.status = function () { return db._adminCommand(\"replSetGetStatus\"); }\n"
|
||||
"rs.isMaster = function () { return db.isMaster(); }\n"
|
||||
"rs.initiate = function (c) { return db._adminCommand({ replSetInitiate: c }); }\n"
|
||||
@@ -2675,6 +2675,16 @@ const StringData _jscode_raw_db =
|
||||
"}\n"
|
||||
"return ret;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype.setSlaveOk = function( value ) {\n"
|
||||
"if( value == undefined ) value = true;\n"
|
||||
"this._slaveOk = value;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype.getSlaveOk = function() {\n"
|
||||
"if (this._slaveOk != undefined) return this._slaveOk;\n"
|
||||
"return this._mongo.getSlaveOk();\n"
|
||||
"}\n"
|
||||
;
|
||||
extern const JSFile db;
|
||||
const JSFile db = { "shell/db.js" , _jscode_raw_db };
|
||||
@@ -2710,6 +2720,10 @@ const StringData _jscode_raw_mongo =
|
||||
"this.slaveOk = value;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"Mongo.prototype.getSlaveOk = function() {\n"
|
||||
"return this.slaveOk || false;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"Mongo.prototype.getDB = function( name ){\n"
|
||||
"return new DB( this , name );\n"
|
||||
"}\n"
|
||||
@@ -3342,14 +3356,14 @@ const StringData _jscode_raw_collection =
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"DBCollection.prototype.find = function( query , fields , limit , skip ){\n"
|
||||
"DBCollection.prototype.find = function( query , fields , limit , skip, batchSize, options ){\n"
|
||||
"return new DBQuery( this._mongo , this._db , this ,\n"
|
||||
"this._fullName , this._massageObject( query ) , fields , limit , skip );\n"
|
||||
"this._fullName , this._massageObject( query ) , fields , limit , skip , batchSize , options || this.getQueryOptions() );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DBCollection.prototype.findOne = function( query , fields ){\n"
|
||||
"DBCollection.prototype.findOne = function( query , fields, options ){\n"
|
||||
"var cursor = this._mongo.find( this._fullName , this._massageObject( query ) || {} , fields ,\n"
|
||||
"-1 /* limit */ , 0 /* skip*/, 0 /* batchSize */ , 0 /* options */ );\n"
|
||||
"-1 /* limit */ , 0 /* skip*/, 0 /* batchSize */ , options || this.getQueryOptions() /* options */ );\n"
|
||||
"if ( ! cursor.hasNext() )\n"
|
||||
"return null;\n"
|
||||
"var ret = cursor.next();\n"
|
||||
@@ -4044,8 +4058,21 @@ const StringData _jscode_raw_collection =
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DBCollection.prototype.setSlaveOk = function( value ) {\n"
|
||||
"if( value == undefined ) value = true;\n"
|
||||
"this._slaveOk = value;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DBCollection.prototype.getSlaveOk = function() {\n"
|
||||
"if (this._slaveOk != undefined) return this._slaveOk;\n"
|
||||
"return this._db.getSlaveOk();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DBCollection.prototype.getQueryOptions = function() {\n"
|
||||
"var options = 0;\n"
|
||||
"if (this.getSlaveOk()) options |= 4;\n"
|
||||
"return options;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
;
|
||||
extern const JSFile collection;
|
||||
|
||||
Reference in New Issue
Block a user