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" })
|
@Table({ tableName: "documents", modelName: "document" })
|
||||||
@Fix
|
@Fix
|
||||||
@@ -365,21 +352,13 @@ class Document extends ParanoidModel {
|
|||||||
views: View[];
|
views: View[];
|
||||||
|
|
||||||
static defaultScopeWithUser(userId: string) {
|
static defaultScopeWithUser(userId: string) {
|
||||||
const starredScope: Readonly<ScopeOptions> = {
|
|
||||||
method: ["withStarred", userId],
|
|
||||||
};
|
|
||||||
const collectionScope: Readonly<ScopeOptions> = {
|
const collectionScope: Readonly<ScopeOptions> = {
|
||||||
method: ["withCollection", userId],
|
method: ["withCollection", userId],
|
||||||
};
|
};
|
||||||
const viewScope: Readonly<ScopeOptions> = {
|
const viewScope: Readonly<ScopeOptions> = {
|
||||||
method: ["withViews", userId],
|
method: ["withViews", userId],
|
||||||
};
|
};
|
||||||
return this.scope([
|
return this.scope(["defaultScope", collectionScope, viewScope]);
|
||||||
"defaultScope",
|
|
||||||
starredScope,
|
|
||||||
collectionScope,
|
|
||||||
viewScope,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findByPk(
|
static async findByPk(
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ export default async function present(
|
|||||||
template: document.template,
|
template: document.template,
|
||||||
templateId: document.templateId,
|
templateId: document.templateId,
|
||||||
collaboratorIds: [],
|
collaboratorIds: [],
|
||||||
starred: document.starred ? !!document.starred.length : undefined,
|
|
||||||
revision: document.revisionCount,
|
revision: document.revisionCount,
|
||||||
fullWidth: document.fullWidth,
|
fullWidth: document.fullWidth,
|
||||||
collectionId: undefined,
|
collectionId: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user