var allCollections = db.getCollectionNames();
for (var i = 0; i < allCollections.length; ++i) {
var collectioname = allCollections[i];
if (collectioname === 'system.indexes')
continue;
db.runCommand(
{ "mapreduce" : collectioname, "map" : function()
{
for (var key in this) {
emit(key, null);
}
}, "reduce" : function(key, stuff) {
return null;
}, "out":mongo_test + "_keys"
}) }
output
{ "_id" : "_id", "value" : null }
{ "_id" : "collection_name", "value" : null }
{ "_id" : "database", "value" : null }
{ "_id" : "host", "value" : null }
{ "_id" : "port", "value" : null }
{ "_id" : "cardid", "value" : null }
{ "_id" : "ccard", "value" : null }
{ "_id" : "creditcardnum", "value" : null }
{ "_id" : "date", "value" : null }
{ "_id" : "value", "value" : null }
null の代わりに「値」フィールドに collectionname が必要です。