índice de exportación mongodb (estructura de tabla)

Exportar script de índice

Compatible con índice único y configuración de tiempo de espera

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)}")}}


Por favor dame un cumplido

Gracias

17 artículos originales publicados · ganó 24 · vistas 280,000 +

Supongo que te gusta

Origin blog.csdn.net/qq_22956867/article/details/102917841
Recomendado
Clasificación