From fd9ef3ab22477ac81adaf1ed5a04b534ef90db3b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 10 Mar 2022 09:02:23 -0800 Subject: [PATCH] perf: Document.state still queried in documents.search endpoint --- server/models/Document.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/server/models/Document.ts b/server/models/Document.ts index 9b8159be7..cca01e9f5 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -610,6 +610,7 @@ class Document extends ParanoidModel { // Final query to get associated document data const documents = await this.scope([ + "defaultScope", { method: ["withViews", user.id], }, @@ -620,18 +621,6 @@ class Document extends ParanoidModel { where: { id: map(results, "id"), }, - include: [ - { - model: User, - as: "createdBy", - paranoid: false, - }, - { - model: User, - as: "updatedBy", - paranoid: false, - }, - ], }); return { results: map(results, (result: any) => ({