diff --git a/server/models/Collection.ts b/server/models/Collection.ts index 18cc68f53..b4f0d2337 100644 --- a/server/models/Collection.ts +++ b/server/models/Collection.ts @@ -457,10 +457,11 @@ class Collection extends ParanoidModel { parentDocumentId: documentId, }, }); - childDocuments.forEach(async (child) => { + + for (const child of childDocuments) { await loopChildren(child.id, opts); await child.destroy(opts); - }); + } }; await loopChildren(document.id, options); diff --git a/server/models/Document.ts b/server/models/Document.ts index 04b5249c3..db2898cd1 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -568,12 +568,12 @@ class Document extends ParanoidModel { parentDocumentId, }, }); - childDocuments.forEach(async (child) => { + for (const child of childDocuments) { await archiveChildren(child.id); child.archivedAt = archivedAt; child.lastModifiedById = userId; await child.save(options); - }); + } }; await archiveChildren(this.id); diff --git a/server/queues/tasks/ImportJSONTask.ts b/server/queues/tasks/ImportJSONTask.ts index b0c15d453..e6d8b82ba 100644 --- a/server/queues/tasks/ImportJSONTask.ts +++ b/server/queues/tasks/ImportJSONTask.ts @@ -62,7 +62,7 @@ export default class ImportJSONTask extends ImportTask { documents: { [id: string]: DocumentJSONExport }, collectionId: string ) { - Object.values(documents).forEach(async (node) => { + Object.values(documents).forEach((node) => { const id = uuidv4(); output.documents.push({ ...node, @@ -89,7 +89,7 @@ export default class ImportJSONTask extends ImportTask { async function mapAttachments(attachments: { [id: string]: AttachmentJSONExport; }) { - Object.values(attachments).forEach(async (node) => { + Object.values(attachments).forEach((node) => { const id = uuidv4(); const zipObject = zip.files[node.key]; const mimeType = mime.lookup(node.key) || "application/octet-stream";