mongodbエクスポートインデックス(テーブル構造)

インデックススクリプトのエクスポート

一意のインデックスと互換性があり、タイムアウト構成

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(
    "try{ db.getCollection(\""+collection+"\").ensureIndex("+JSON.stringify(next.key)+",{background:1, unique:" + (next.unique || false) + "" + (next.expireAfterSeconds > 0 ? ", expireAfterSeconds :" + next.expireAfterSeconds  : "") + " })}catch(e){print(e)}")}}


褒めてください

ありがとう

元の記事を17件公開 24 件を獲得 28万回以上表示

おすすめ

転載: blog.csdn.net/qq_22956867/article/details/102917841