feat: Add button to empty trash (#6772)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import uniq from "lodash/uniq";
|
||||
import { QueryTypes } from "sequelize";
|
||||
import { Op, QueryTypes } from "sequelize";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { Document, Attachment } from "@server/models";
|
||||
import DeleteAttachmentTask from "@server/queues/tasks/DeleteAttachmentTask";
|
||||
@@ -73,6 +73,21 @@ export default async function documentPermanentDeleter(documents: Document[]) {
|
||||
);
|
||||
}
|
||||
|
||||
const documentIds = documents.map((document) => document.id);
|
||||
await Document.update(
|
||||
{
|
||||
parentDocumentId: null,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
parentDocumentId: {
|
||||
[Op.in]: documentIds,
|
||||
},
|
||||
},
|
||||
paranoid: false,
|
||||
}
|
||||
);
|
||||
|
||||
return Document.scope("withDrafts").destroy({
|
||||
where: {
|
||||
id: documents.map((document) => document.id),
|
||||
|
||||
Reference in New Issue
Block a user