perf: Don't load CRDT state from database by default (#3215)

This commit is contained in:
Tom Moor
2022-03-09 20:07:10 -08:00
committed by GitHub
parent 5efeb90fdd
commit d399e1048a
6 changed files with 27 additions and 8 deletions

View File

@@ -69,6 +69,9 @@ const serializer = new MarkdownSerializer();
export const DOCUMENT_VERSION = 2;
@DefaultScope(() => ({
attributes: {
exclude: ["state"],
},
include: [
{
model: User,
@@ -112,7 +115,18 @@ export const DOCUMENT_VERSION = 2;
],
};
},
withUnpublished: {
withoutState: {
attributes: {
exclude: ["state"],
},
},
withState: {
attributes: {
// resets to include the state column
exclude: [],
},
},
withDrafts: {
include: [
{
model: User,
@@ -370,7 +384,8 @@ class Document extends ParanoidModel {
// allow default preloading of collection membership if `userId` is passed in find options
// almost every endpoint needs the collection membership to determine policy permissions.
const scope = this.scope([
"withUnpublished",
"withoutState",
"withDrafts",
{
method: ["withCollection", options.userId, options.paranoid],
},

View File

@@ -34,7 +34,7 @@ import Fix from "./decorators/Fix";
return {
include: [
{
model: Document.scope("withUnpublished"),
model: Document.scope("withDrafts"),
paranoid: true,
as: "document",
include: [