MongoDB remove mapreduce collection

前端 未结 2 1057
-上瘾入骨i
-上瘾入骨i 2021-02-15 06:44

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

2条回答
  •  萌比男神i
    2021-02-15 07:09

    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.

提交回复
热议问题