MongoDB remove mapreduce collection

前端 未结 1 1526
夕颜
夕颜 2021-02-15 06:31

Due to error in client code, mongodb have created many \"mr.mapreduce....\" collections, how to remove them all (by mask maybe).

1条回答
  •  失恋的感觉
    2021-02-15 07:24

    I run script in interactive shell:

    function f() {
        var names = db.getCollectionNames();
        for(var i = 0; i < names.length; i++){
        if(names[i].indexOf("mr.") == 0){
        db[names[i]].drop();}}};
    f();
    

    It resolved my problem.

    0 讨论(0)
提交回复
热议问题