perf: Remove withStarred scope and starred property on documents

closes #3081
This commit is contained in:
Tom Moor
2022-02-09 19:51:51 -08:00
parent 5bc4405b23
commit b3f33c1101
2 changed files with 1 additions and 23 deletions

View File

@@ -144,19 +144,6 @@ export const DOCUMENT_VERSION = 2;
],
};
},
withStarred: (userId: string) => ({
include: [
{
model: Star,
as: "starred",
where: {
userId,
},
required: false,
separate: true,
},
],
}),
}))
@Table({ tableName: "documents", modelName: "document" })
@Fix
@@ -365,21 +352,13 @@ class Document extends ParanoidModel {
views: View[];
static defaultScopeWithUser(userId: string) {
const starredScope: Readonly<ScopeOptions> = {
method: ["withStarred", userId],
};
const collectionScope: Readonly<ScopeOptions> = {
method: ["withCollection", userId],
};
const viewScope: Readonly<ScopeOptions> = {
method: ["withViews", userId],
};
return this.scope([
"defaultScope",
starredScope,
collectionScope,
viewScope,
]);
return this.scope(["defaultScope", collectionScope, viewScope]);
}
static async findByPk(

View File

@@ -56,7 +56,6 @@ export default async function present(
template: document.template,
templateId: document.templateId,
collaboratorIds: [],
starred: document.starred ? !!document.starred.length : undefined,
revision: document.revisionCount,
fullWidth: document.fullWidth,
collectionId: undefined,