|
@@ -1,12 +1,11 @@
|
|
|
-import { getOrCreateModel } from '@growi/core';
|
|
|
|
|
import mongoose, {
|
|
import mongoose, {
|
|
|
Schema, Model, Document, QueryOptions, FilterQuery,
|
|
Schema, Model, Document, QueryOptions, FilterQuery,
|
|
|
} from 'mongoose';
|
|
} from 'mongoose';
|
|
|
|
|
+import { getOrCreateModel } from '@growi/core';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
IPageForResuming, IUserForResuming, IOptionsForResuming,
|
|
IPageForResuming, IUserForResuming, IOptionsForResuming,
|
|
|
} from '~/server/interfaces/page-operation';
|
|
} from '~/server/interfaces/page-operation';
|
|
|
-
|
|
|
|
|
import { ObjectIdLike } from '../interfaces/mongoose-utils';
|
|
import { ObjectIdLike } from '../interfaces/mongoose-utils';
|
|
|
|
|
|
|
|
type IObjectId = mongoose.Types.ObjectId;
|
|
type IObjectId = mongoose.Types.ObjectId;
|
|
@@ -28,11 +27,6 @@ export const PageActionStage = {
|
|
|
} as const;
|
|
} as const;
|
|
|
export type PageActionStage = typeof PageActionStage[keyof typeof PageActionStage];
|
|
export type PageActionStage = typeof PageActionStage[keyof typeof PageActionStage];
|
|
|
|
|
|
|
|
-export const PageOperationAutoUpdateTimerType = {
|
|
|
|
|
- ExtendSec: 5, // add this second(s) to current time
|
|
|
|
|
- IntervalSec: 5, // every this second(s)
|
|
|
|
|
-} as const;
|
|
|
|
|
-
|
|
|
|
|
/*
|
|
/*
|
|
|
* Main Schema
|
|
* Main Schema
|
|
|
*/
|
|
*/
|
|
@@ -45,7 +39,6 @@ export interface IPageOperation {
|
|
|
user: IUserForResuming,
|
|
user: IUserForResuming,
|
|
|
options?: IOptionsForResuming,
|
|
options?: IOptionsForResuming,
|
|
|
incForUpdatingDescendantCount?: number,
|
|
incForUpdatingDescendantCount?: number,
|
|
|
- unprocessableExpiryDate?: Date,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface PageOperationDocument extends IPageOperation, Document {}
|
|
export interface PageOperationDocument extends IPageOperation, Document {}
|
|
@@ -101,7 +94,6 @@ const schema = new Schema<PageOperationDocument, PageOperationModel>({
|
|
|
user: { type: userSchemaForResuming, required: true },
|
|
user: { type: userSchemaForResuming, required: true },
|
|
|
options: { type: optionsSchemaForResuming },
|
|
options: { type: optionsSchemaForResuming },
|
|
|
incForUpdatingDescendantCount: { type: Number },
|
|
incForUpdatingDescendantCount: { type: Number },
|
|
|
- unprocessableExpiryDate: { type: Date, default: null },
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
schema.statics.findByIdAndUpdatePageActionStage = async function(
|
|
schema.statics.findByIdAndUpdatePageActionStage = async function(
|
|
@@ -124,8 +116,4 @@ schema.statics.findMainOps = async function(
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-schema.statics.cleanup = async function(excludeActionTypeList: PageActionType[], excludeStage: PageActionStage): Promise<void> {
|
|
|
|
|
- await this.deleteMany({ actionType: { $nin: excludeActionTypeList }, actionStage: { $ne: excludeStage } });
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);
|
|
export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);
|