MongoDB 删除 MapReduce 集合

标签 mongodb mongodb-.net-driver

由于客户端代码中的错误,mongodb 创建了许多“mr.mapreduce....”集合,如何将它们全部删除(可能通过掩码)。

最佳答案

我在交互式 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 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4163157/

相关文章:

c# - 使用 MongoDB 的官方 C# 驱动程序的按位枚举(标志)查询

mongodb - 是否有可用的免费/开源 Mongo DB 浏览器?

python - MongoDB 和 PyMongo - 类似 SQL 的列

c# - 在 C# 中运行 MongoDump/MongoRestore

c# - 在 MongoDB C# 中展开然后分组聚合

Python eve ?where 查询返回空结果

c# - Mongo DB中的Upserting和Id问题

javascript - 如何更新 Mongoose 中的数组元素 - MongoDB

node.js - 使用 mongodb 提醒重复日历事件

mongodb获取最大值到一个数字