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" );
|
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;
|
return this._mongo;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB.prototype.getSisterDB = function( name ){
|
DB.prototype.getSiblingDB = function( name ){
|
||||||
return this.getMongo().getDB( name );
|
return this.getMongo().getDB( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB.prototype.getSisterDB = DB.prototype.getSiblingDB;
|
||||||
|
|
||||||
DB.prototype.getName = function(){
|
DB.prototype.getName = function(){
|
||||||
return this._name;
|
return this._name;
|
||||||
}
|
}
|
||||||
@ -49,7 +51,7 @@ DB.prototype._dbCommand = DB.prototype.runCommand;
|
|||||||
DB.prototype.adminCommand = function( obj ){
|
DB.prototype.adminCommand = function( obj ){
|
||||||
if ( this._name == "admin" )
|
if ( this._name == "admin" )
|
||||||
return this.runCommand( obj );
|
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
|
DB.prototype._adminCommand = DB.prototype.adminCommand; // alias old name
|
||||||
@ -289,7 +291,7 @@ DB.prototype.help = function() {
|
|||||||
print("\tdb.getProfilingLevel() - deprecated");
|
print("\tdb.getProfilingLevel() - deprecated");
|
||||||
print("\tdb.getProfilingStatus() - returns if profiling is on and slow threshold ");
|
print("\tdb.getProfilingStatus() - returns if profiling is on and slow threshold ");
|
||||||
print("\tdb.getReplicationInfo()");
|
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.isMaster() check replica primary status");
|
||||||
print("\tdb.killOp(opid) kills the current operation in the db");
|
print("\tdb.killOp(opid) kills the current operation in the db");
|
||||||
print("\tdb.listCommands() lists all the db commands");
|
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
|
* of date than that, it can't recover without a complete resync
|
||||||
*/
|
*/
|
||||||
DB.prototype.getReplicationInfo = function() {
|
DB.prototype.getReplicationInfo = function() {
|
||||||
var db = this.getSisterDB("local");
|
var db = this.getSiblingDB("local");
|
||||||
|
|
||||||
var result = { };
|
var result = { };
|
||||||
var oplog;
|
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 ) {
|
if( L.sources.count() != 0 ) {
|
||||||
L.sources.find().forEach(g);
|
L.sources.find().forEach(g);
|
||||||
}
|
}
|
||||||
@ -754,7 +756,7 @@ DB.prototype.listCommands = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
DB.prototype.printShardingStatus = function(){
|
DB.prototype.printShardingStatus = function(){
|
||||||
printShardingStatus( this.getSisterDB( "config" ) );
|
printShardingStatus( this.getSiblingDB( "config" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
DB.autocomplete = function(obj){
|
DB.autocomplete = function(obj){
|
||||||
|
@ -1474,10 +1474,12 @@ const StringData _jscode_raw_db =
|
|||||||
"return this._mongo;\n"
|
"return this._mongo;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DB.prototype.getSisterDB = function( name ){\n"
|
"DB.prototype.getSiblingDB = function( name ){\n"
|
||||||
"return this.getMongo().getDB( name );\n"
|
"return this.getMongo().getDB( name );\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"DB.prototype.getSisterDB = DB.prototype.getSiblingDB;\n"
|
||||||
|
"\n"
|
||||||
"DB.prototype.getName = function(){\n"
|
"DB.prototype.getName = function(){\n"
|
||||||
"return this._name;\n"
|
"return this._name;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
@ -1511,7 +1513,7 @@ const StringData _jscode_raw_db =
|
|||||||
"DB.prototype.adminCommand = function( obj ){\n"
|
"DB.prototype.adminCommand = function( obj ){\n"
|
||||||
"if ( this._name == \"admin\" )\n"
|
"if ( this._name == \"admin\" )\n"
|
||||||
"return this.runCommand( obj );\n"
|
"return this.runCommand( obj );\n"
|
||||||
"return this.getSisterDB( \"admin\" ).runCommand( obj );\n"
|
"return this.getSiblingDB( \"admin\" ).runCommand( obj );\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DB.prototype._adminCommand = DB.prototype.adminCommand; // alias old name\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.getProfilingLevel() - deprecated\");\n"
|
||||||
"print(\"\\tdb.getProfilingStatus() - returns if profiling is on and slow threshold \");\n"
|
"print(\"\\tdb.getProfilingStatus() - returns if profiling is on and slow threshold \");\n"
|
||||||
"print(\"\\tdb.getReplicationInfo()\");\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.isMaster() check replica primary status\");\n"
|
||||||
"print(\"\\tdb.killOp(opid) kills the current operation in the db\");\n"
|
"print(\"\\tdb.killOp(opid) kills the current operation in the db\");\n"
|
||||||
"print(\"\\tdb.listCommands() lists all the db commands\");\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"
|
"* of date than that, it can't recover without a complete resync\n"
|
||||||
"*/\n"
|
"*/\n"
|
||||||
"DB.prototype.getReplicationInfo = function() {\n"
|
"DB.prototype.getReplicationInfo = function() {\n"
|
||||||
"var db = this.getSisterDB(\"local\");\n"
|
"var db = this.getSiblingDB(\"local\");\n"
|
||||||
"\n"
|
"\n"
|
||||||
"var result = { };\n"
|
"var result = { };\n"
|
||||||
"var oplog;\n"
|
"var oplog;\n"
|
||||||
@ -2160,7 +2162,7 @@ const StringData _jscode_raw_db =
|
|||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"var L = this.getSisterDB(\"local\");\n"
|
"var L = this.getSiblingDB(\"local\");\n"
|
||||||
"if( L.sources.count() != 0 ) {\n"
|
"if( L.sources.count() != 0 ) {\n"
|
||||||
"L.sources.find().forEach(g);\n"
|
"L.sources.find().forEach(g);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
@ -2216,7 +2218,7 @@ const StringData _jscode_raw_db =
|
|||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DB.prototype.printShardingStatus = function(){\n"
|
"DB.prototype.printShardingStatus = function(){\n"
|
||||||
"printShardingStatus( this.getSisterDB( \"config\" ) );\n"
|
"printShardingStatus( this.getSiblingDB( \"config\" ) );\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"DB.autocomplete = function(obj){\n"
|
"DB.autocomplete = function(obj){\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user