core: delete related ddoc when deleting tdoc

This commit is contained in:
undefined committed 2021-08-25 05:19:33 +00:00
1 parent c78fc82d5b
commit 4c6aeeb914
6 files changed
+26 -11

No files matched your search

+1
View File
@@ -458,6 +458,7 @@ export async function del(domainId: string, tid: ObjectID, type: Type = document
await Promise.all([
document.deleteOne(domainId, type, tid),
document.deleteMultiStatus(domainId, type, { docId: tid }),
document.deleteMulti(domainId, document.TYPE_DISCUSSION, { parentType: type, parentId: tid }),
]);
}
+12
View File
@@ -458,6 +458,18 @@ const scripts: UpgradeScript[] = [
);
return true;
},
async function _41_42() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain(async (ddoc) => {
const cursor = discussion.getMulti(ddoc._id, { parentType: document.TYPE_CONTEST });
while (await cursor.hasNext()) {
const doc = await cursor.next();
const tdoc = await document.coll.findOne({ docType: doc.parentType, docId: doc.parentId });
if (!tdoc) await discussion.del(ddoc._id, doc.docId);
}
});
return true;
},
];
export default scripts;