Last active
November 18, 2015 13:18
-
-
Save robjens/5e0f3527de2398d4e12f to your computer and use it in GitHub Desktop.
MongoDb standalone initialization script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var hosts = [ | |
| 'hostname.mongo.server' | |
| ]; | |
| for( var hosti in hosts ){ | |
| var hostname = hosts[hosti]; | |
| print(hostname); | |
| var dbo = new Mongo(hostname + ":27017").getDB('test'); | |
| dbo.setSlaveOk(); | |
| var dbarray = dbo.adminCommand('listDatabases').databases | |
| for( var dbi in dbarray ){ | |
| var dbname = dbarray[dbi].name; | |
| print(dbname); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment