mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
added getSiblingDB SERVER-2159
This commit is contained in:
parent
37512ba181
commit
1808b56939
@ -70,3 +70,8 @@ assert( asserted, "should have asserted" );
|
||||
|
||||
dd( "g" );
|
||||
|
||||
|
||||
|
||||
assert.eq( "foo" , db.getSisterDB( "foo" ).getName() )
|
||||
assert.eq( "foo" , db.getSiblingDB( "foo" ).getName() )
|
||||
|
||||
|
14
shell/db.js
14
shell/db.js
@ -12,10 +12,12 @@ DB.prototype.getMongo = function(){
|
||||
return this._mongo;
|
||||
}
|
||||
|
||||
DB.prototype.getSisterDB = function( name ){
|
||||
DB.prototype.getSiblingDB = function( name ){
|
||||
return this.getMongo().getDB( name );
|
||||
}
|
||||
|
||||
DB.prototype.getSisterDB = DB.prototype.getSiblingDB;
|
||||
|
||||
DB.prototype.getName = function(){
|
||||
return this._name;
|
||||
}
|
||||
@ -49,7 +51,7 @@ DB.prototype._dbCommand = DB.prototype.runCommand;
|
||||
DB.prototype.adminCommand = function( obj ){
|
||||
if ( this._name == "admin" )
|
||||
return this.runCommand( obj );
|
||||
return this.getSisterDB( "admin" ).runCommand( obj );
|
||||
return this.getSiblingDB( "admin" ).runCommand( obj );
|
||||
}
|
||||
|
||||
DB.prototype._adminCommand = DB.prototype.adminCommand; // alias old name
|
||||
@ -289,7 +291,7 @@ DB.prototype.help = function() {
|
||||
print("\tdb.getProfilingLevel() - deprecated");
|
||||
print("\tdb.getProfilingStatus() - returns if profiling is on and slow threshold ");
|
||||
print("\tdb.getReplicationInfo()");
|
||||
print("\tdb.getSisterDB(name) get the db at the same server as this one");
|
||||
print("\tdb.getSiblingDB(name) get the db at the same server as this one");
|
||||
print("\tdb.isMaster() check replica primary status");
|
||||
print("\tdb.killOp(opid) kills the current operation in the db");
|
||||
print("\tdb.listCommands() lists all the db commands");
|
||||
@ -591,7 +593,7 @@ DB.tsToSeconds = function(x){
|
||||
* of date than that, it can't recover without a complete resync
|
||||
*/
|
||||
DB.prototype.getReplicationInfo = function() {
|
||||
var db = this.getSisterDB("local");
|
||||
var db = this.getSiblingDB("local");
|
||||
|
||||
var result = { };
|
||||
var oplog;
|
||||
@ -698,7 +700,7 @@ DB.prototype.printSlaveReplicationInfo = function() {
|
||||
}
|
||||
};
|
||||
|
||||
var L = this.getSisterDB("local");
|
||||
var L = this.getSiblingDB("local");
|
||||
if( L.sources.count() != 0 ) {
|
||||
L.sources.find().forEach(g);
|
||||
}
|
||||
@ -754,7 +756,7 @@ DB.prototype.listCommands = function(){
|
||||
}
|
||||
|
||||
DB.prototype.printShardingStatus = function(){
|
||||
printShardingStatus( this.getSisterDB( "config" ) );
|
||||
printShardingStatus( this.getSiblingDB( "config" ) );
|
||||
}
|
||||
|
||||
DB.autocomplete = function(obj){
|
||||
|
@ -1474,10 +1474,12 @@ const StringData _jscode_raw_db =
|
||||
"return this._mongo;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype.getSisterDB = function( name ){\n"
|
||||
"DB.prototype.getSiblingDB = function( name ){\n"
|
||||
"return this.getMongo().getDB( name );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype.getSisterDB = DB.prototype.getSiblingDB;\n"
|
||||
"\n"
|
||||
"DB.prototype.getName = function(){\n"
|
||||
"return this._name;\n"
|
||||
"}\n"
|
||||
@ -1511,7 +1513,7 @@ const StringData _jscode_raw_db =
|
||||
"DB.prototype.adminCommand = function( obj ){\n"
|
||||
"if ( this._name == \"admin\" )\n"
|
||||
"return this.runCommand( obj );\n"
|
||||
"return this.getSisterDB( \"admin\" ).runCommand( obj );\n"
|
||||
"return this.getSiblingDB( \"admin\" ).runCommand( obj );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype._adminCommand = DB.prototype.adminCommand; // alias old name\n"
|
||||
@ -1751,7 +1753,7 @@ const StringData _jscode_raw_db =
|
||||
"print(\"\\tdb.getProfilingLevel() - deprecated\");\n"
|
||||
"print(\"\\tdb.getProfilingStatus() - returns if profiling is on and slow threshold \");\n"
|
||||
"print(\"\\tdb.getReplicationInfo()\");\n"
|
||||
"print(\"\\tdb.getSisterDB(name) get the db at the same server as this one\");\n"
|
||||
"print(\"\\tdb.getSiblingDB(name) get the db at the same server as this one\");\n"
|
||||
"print(\"\\tdb.isMaster() check replica primary status\");\n"
|
||||
"print(\"\\tdb.killOp(opid) kills the current operation in the db\");\n"
|
||||
"print(\"\\tdb.listCommands() lists all the db commands\");\n"
|
||||
@ -2053,7 +2055,7 @@ const StringData _jscode_raw_db =
|
||||
"* of date than that, it can't recover without a complete resync\n"
|
||||
"*/\n"
|
||||
"DB.prototype.getReplicationInfo = function() {\n"
|
||||
"var db = this.getSisterDB(\"local\");\n"
|
||||
"var db = this.getSiblingDB(\"local\");\n"
|
||||
"\n"
|
||||
"var result = { };\n"
|
||||
"var oplog;\n"
|
||||
@ -2160,7 +2162,7 @@ const StringData _jscode_raw_db =
|
||||
"}\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"var L = this.getSisterDB(\"local\");\n"
|
||||
"var L = this.getSiblingDB(\"local\");\n"
|
||||
"if( L.sources.count() != 0 ) {\n"
|
||||
"L.sources.find().forEach(g);\n"
|
||||
"}\n"
|
||||
@ -2216,7 +2218,7 @@ const StringData _jscode_raw_db =
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.prototype.printShardingStatus = function(){\n"
|
||||
"printShardingStatus( this.getSisterDB( \"config\" ) );\n"
|
||||
"printShardingStatus( this.getSiblingDB( \"config\" ) );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"DB.autocomplete = function(obj){\n"
|
||||
|
Loading…
Reference in New Issue
Block a user