MongDB 索引备份
作者:
嗚嗚雲 | 来源:发表于
2022-11-30 14:37 被阅读0次
var collectionList = db.getCollectionNames();
for (var index in collectionList) {
var collection = collectionList[index];
var cur = db.getCollection(collection).getIndexes();
if (cur.length == 1) {
continue;
}
for (var index1 in cur) {
var next = cur[index1];
if (next["key"]["_id"] == '1') {
continue;
}
print(" db.getCollection(\"" + collection + "\").ensureIndex(" + JSON.stringify(next.key) + ",{background:1, unique:" + (next.unique || false) + "" + (next.expireAfterSeconds > 0 ? ", expireAfterSeconds :" + next.expireAfterSeconds: "") + " })"
)
}
};
本文标题:MongDB 索引备份
本文链接:https://www.haomeiwen.com/subject/goqsfdtx.html
网友评论