|
@@ -7,8 +7,11 @@ import {
|
|
|
IPageForResuming, IUserForResuming, IOptionsForResuming,
|
|
IPageForResuming, IUserForResuming, IOptionsForResuming,
|
|
|
} from '~/server/interfaces/page-operation';
|
|
} from '~/server/interfaces/page-operation';
|
|
|
|
|
|
|
|
|
|
+import loggerFactory from '../../utils/logger';
|
|
|
import { ObjectIdLike } from '../interfaces/mongoose-utils';
|
|
import { ObjectIdLike } from '../interfaces/mongoose-utils';
|
|
|
|
|
|
|
|
|
|
+const logger = loggerFactory('growi:models:page-operation');
|
|
|
|
|
+
|
|
|
type IObjectId = mongoose.Types.ObjectId;
|
|
type IObjectId = mongoose.Types.ObjectId;
|
|
|
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
|
|
|
|
|
@@ -48,6 +51,8 @@ export type PageOperationDocumentHasId = PageOperationDocument & { _id: ObjectId
|
|
|
|
|
|
|
|
export interface PageOperationModel extends Model<PageOperationDocument> {
|
|
export interface PageOperationModel extends Model<PageOperationDocument> {
|
|
|
findByIdAndUpdatePageActionStage(pageOpId: ObjectIdLike, stage: PageActionStage): Promise<PageOperationDocumentHasId | null>
|
|
findByIdAndUpdatePageActionStage(pageOpId: ObjectIdLike, stage: PageActionStage): Promise<PageOperationDocumentHasId | null>
|
|
|
|
|
+ findMainOps(filter?: FilterQuery<PageOperationDocument>, projection?: any, options?: QueryOptions): Promise<PageOperationDocumentHasId[]>
|
|
|
|
|
+ deleteByActionTypes(deleteTypeList: PageActionType[]): Promise<void>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const pageSchemaForResuming = new Schema<IPageForResuming>({
|
|
const pageSchemaForResuming = new Schema<IPageForResuming>({
|
|
@@ -116,4 +121,12 @@ schema.statics.findMainOps = async function(
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+schema.statics.deleteByActionTypes = async function(
|
|
|
|
|
+ actionTypes: PageActionType[],
|
|
|
|
|
+): Promise<void> {
|
|
|
|
|
+
|
|
|
|
|
+ await this.deleteMany({ actionType: { $in: actionTypes } });
|
|
|
|
|
+ logger.info(`Deleted all PageOperation documents with actionType: [${actionTypes}]`);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);
|
|
export default getOrCreateModel<PageOperationDocument, PageOperationModel>('PageOperation', schema);
|