MongoDB删除mapreduce集合 [英] MongoDB remove mapreduce collection
本文介绍了MongoDB删除mapreduce集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于客户端代码中的错误,mongodb创建了许多"mr.mapreduce ...."集合,以及如何将其全部删除(可能是通过掩码).
Due to error in client code, mongodb have created many "mr.mapreduce...." collections, how to remove them all (by mask maybe).
推荐答案
我在交互式shell中运行脚本:
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();
它解决了我的问题.
这篇关于MongoDB删除mapreduce集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文