Skip to content

Instantly share code, notes, and snippets.

@mvivekk
mvivekk / mongo-struc.js
Created June 8, 2017 12:55 — forked from hkasera/mongo-struc.js
A script for mongo shell to get the collection structure.
var conn = new Mongo();
db = conn.getDB(<DB_NAME>);
var cursor = db.<COLLECTION>.find();
var items = [];
items = cursor.toArray();
var dbstruc = {};
for (var i = 0; i < items.length; ++i) {
var target = items[i];
getKP(target,dbstruc);
}