Skip to content

Instantly share code, notes, and snippets.

View oosidat's full-sized avatar

Osama Sidat oosidat

View GitHub Profile
@wpottier
wpottier / show-indexes.js
Last active July 2, 2021 02:18
MongoDB copy indexes
db.getCollectionNames().forEach(function(collection) {
indexes = db[collection].getIndexes();
indexes.forEach(function (c) {
opt = '';
ixkey = JSON.stringify(c.key, null, 1).replace(/(\r\n|\n|\r)/gm,"");
ns = c.ns.substr(c.ns.indexOf(".") + 1, c.ns.length);
for (var key in c) {
if (key != 'key' && key != 'ns' && key != 'v') {
if (opt != '') { opt+= ','}
if (c.hasOwnProperty(key)) {