getSiblingDB(database)
This method is used to return another database without modifying the db variable in the shell environment.
We can also use db.getSiblingDB() as an alternative to the use <database> helper.
Note:
This is particularly useful when writing scripts using the mongo shell where the use helper is not available.
Syntax:
db.getSiblingDB(database)
Example
MongoDB
db.getSiblingDB('admin')
Output:
admin
No comments:
Post a Comment