perf: Remove withStarred scope and starred property on documents
closes #3081
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user