清理数据时发现数据库并没有文档内写的wf_instance的集合 ,我应该咋办

问答  收藏
2 / 167

我用的是
use mdworkflow

db.getCollection("wf_instance").find({ "completeDate": { $lte: ISODate("2023-12-31T16:00:00.000Z") } }).forEach(
function(ref){
db.getCollection("wf_instance").remove({"_id" :ref._id});
db.getCollection("wf_subInstanceActivity").remove({"instanceId" :ref._id.valueOf()});
db.getCollection("wf_subInstanceCallback").remove({"_id" :ref._id});
db.getCollection("app_multiple_catch").remove({"instanceId" :ref._id.valueOf()});
db.getCollection("custom_apipackageapi_catch").remove({"instanceId" :ref._id.valueOf()});
}
);

但是返回结果都是零,我查询了数据库
MongoDB shell version v3.4.24
connecting to: mongodb:/吧 hi 赛后 ihau:27017/
MongoDB server version: 3.4.24
Server has startup warnings:
2024-06-10T04:25:09.153+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2024-06-10T04:25:09.153+0800 I CONTROL [initandlisten]

db.wf_instance.countDocuments({ "completeDate": { lte: ISODate("2023-12-31T16:00:00.000Z") } }) 2024-06-11T10:39:23.823+0800 E QUERY [thread1] TypeError: db.wf_instance.countDocuments is not a function : @(shell):1:1 db.wf_instance.count({ "completeDate": { lte: ISODate("2023-12-31T16:00:00.000Z") } })
0
db.wf_subInstanceActivity.count({ "instanceId": { exists: true } }) 0 db.wf_subInstanceCallback.count({ "_id": { exists: true } })
0
db.app_multiple_catch.count({ "instanceId": { exists: true } }) 0 db.custom_apipackageapi_catch.count({ "instanceId": { exists: true } })
0
db.wf_instance.count({ "completeDate": { lte: ISODate("2024-05-31T16:00:00.000Z") } }) 0 db.wf_instance.find({ "completeDate": { lte: ISODate("2024-05-31T16:00:00.000Z") } }).limit(1)
db.wf_instance.find().sort({ "completeDate": -1 }).limit(1)
db.wf_instance.count()
0
db.getCollectionNames().includes("wf_instance")
false
db.getCollection("app_multiple_catch").createIndex({ "instanceId": 1 }, {background: true}))
2024-06-11T11:11:11.781+0800 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:91
db.getCollectionNames().includes("wf_instance")
false

前面一个步骤
use mdworkflow
switched to db mdworkflow
db.getCollection("code_catch").remove({});
WriteResult({ "nRemoved" : 1584 })
db.getCollection("hooks_catch").remove({});
WriteResult({ "nRemoved" : 25365 })
db.getCollection("webhooks_catch").remove({});
WriteResult({ "nRemoved" : 86 })
是清理成功的 。后面步骤发现压根找不到合集。

现在咋整,数据库现在 400G 了 真的需要清理了。求指点