Skip to content

Instantly share code, notes, and snippets.

/* global db, tojson, tojsononeline, rs, print, printjson */
/* =================================================
* getMongoData.js: MongoDB Config and Schema Report
* =================================================
*
* Copyright MongoDB, Inc, 2015
*
* Gather MongoDB configuration and schema information.
*
/* global db, tojson, tojsononeline, rs, print, printjson */
/* =================================================
* getMongoData.js: MongoDB Config and Schema Report
* =================================================
*
* Copyright MongoDB, Inc, 2015
*
* Gather MongoDB configuration and schema information.
*
db.adminCommand({'listDatabases':1, nameOnly:true}).databases.forEach(function(mydb) {
var dbName = mydb.name;
if (! ["admin", "config", "local"].includes(dbName)) {
var currentDB = db.getSiblingDB(dbName);
var collectionNames = currentDB.getCollectionNames();
collectionNames.forEach(function (collName) {
if (/^system\./.test(collName)){
return;
}
var indexes = currentDB[collName].getIndexes();
test