I am new to python and I am using python 2.6. I wrote a script to fetch all collections from MongoDB databases, Now I am trying to find indexes also using the same script
Here's the code snippet which fetches collections from all DB's
import pymongo
import json
if __name__ == '__main__':
client = pymongo.MongoClient("localhost", 27011, maxPoolSize=50)
d = dict((db, [collection for collection in client[db].collection_names()])
for db in client.database_names())
print json.dumps(d)
and I want to integrate following MongoDB command into the script which will list all indexes present in DB
db.getCollectionNames().forEach(function(collection){indexes = db[collection].getIndexes();print(collection);printjson(indexes.length);indexes.forEach(function(item){print(item.name);});});
How can I achieve that in the script