In the background, I checked that there are multiple indexes for a table in the database.
I built a new table. Is there any way to add all the indexes
Try:
var indexes = db.user.getIndexes(); indexes.forEach(function(index){ delete index.v; delete index.ns; var options = []; for (var option in index) { if (option ! = 'key') { options.push(index['option']); } } db.usertest.createIndex(index.key, options); });