Explorar o código

tidy up imports and exports

Yuki Takei hai 1 ano
pai
achega
7baa435a49
Modificáronse 33 ficheiros con 108 adicións e 60 borrados
  1. 1 1
      apps/app/src/migrations/20220613064207-add-attachment-type-to-existing-attachments.js
  2. 3 1
      apps/app/src/server/models/GlobalNotificationSetting/GlobalNotificationMailSetting.js
  3. 3 1
      apps/app/src/server/models/GlobalNotificationSetting/GlobalNotificationSlackSetting.js
  4. 3 1
      apps/app/src/server/models/bookmark.js
  5. 2 7
      apps/app/src/server/models/index.ts
  6. 3 1
      apps/app/src/server/models/slack-app-integration.js
  7. 3 1
      apps/app/src/server/models/user.js
  8. 1 1
      apps/app/src/server/routes/apiv3/attachment.js
  9. 1 1
      apps/app/src/server/routes/apiv3/customize-setting.js
  10. 9 4
      apps/app/src/server/routes/apiv3/invited.ts
  11. 1 1
      apps/app/src/server/routes/apiv3/notification-setting.js
  12. 5 6
      apps/app/src/server/routes/apiv3/page-listing.ts
  13. 2 3
      apps/app/src/server/routes/apiv3/page/create-page.ts
  14. 2 3
      apps/app/src/server/routes/apiv3/page/update-page.ts
  15. 1 1
      apps/app/src/server/routes/apiv3/pages/index.js
  16. 1 3
      apps/app/src/server/routes/attachment/api.js
  17. 1 1
      apps/app/src/server/routes/attachment/get-brand-logo.ts
  18. 1 1
      apps/app/src/server/routes/attachment/get.ts
  19. 1 1
      apps/app/src/server/routes/comment.js
  20. 4 3
      apps/app/src/server/routes/ogp.ts
  21. 1 1
      apps/app/src/server/routes/page.js
  22. 1 1
      apps/app/src/server/service/attachment.js
  23. 1 1
      apps/app/src/server/service/file-uploader/aws.ts
  24. 8 5
      apps/app/src/server/service/file-uploader/azure.ts
  25. 1 1
      apps/app/src/server/service/file-uploader/file-uploader.ts
  26. 1 1
      apps/app/src/server/service/file-uploader/gcs.ts
  27. 1 1
      apps/app/src/server/service/file-uploader/gridfs.ts
  28. 1 1
      apps/app/src/server/service/file-uploader/local.ts
  29. 1 1
      apps/app/src/server/service/file-uploader/utils/headers.ts
  30. 6 3
      apps/app/src/server/service/g2g-transfer.ts
  31. 1 1
      apps/app/src/server/service/global-notification/global-notification-mail.js
  32. 1 1
      apps/app/src/server/service/global-notification/global-notification-slack.js
  33. 36 0
      apps/app/src/server/service/playground-2.mongodb.js

+ 1 - 1
apps/app/src/migrations/20220613064207-add-attachment-type-to-existing-attachments.js

@@ -1,7 +1,7 @@
 import mongoose from 'mongoose';
 
 import { AttachmentType } from '~/server/interfaces/attachment';
-import { Attachment } from '~/server/models';
+import { Attachment } from '~/server/models/attachment';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 

+ 3 - 1
apps/app/src/server/models/GlobalNotificationSetting/GlobalNotificationMailSetting.js

@@ -7,7 +7,7 @@ const GlobalNotificationSetting = require('./index');
 const GlobalNotificationSettingClass = GlobalNotificationSetting.class;
 const GlobalNotificationSettingSchema = GlobalNotificationSetting.schema;
 
-module.exports = function(crowi) {
+const factory = (crowi) => {
   GlobalNotificationSettingClass.crowi = crowi;
   GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
 
@@ -23,3 +23,5 @@ module.exports = function(crowi) {
 
   return GlobalNotificationMailSettingModel;
 };
+
+export default factory;

+ 3 - 1
apps/app/src/server/models/GlobalNotificationSetting/GlobalNotificationSlackSetting.js

@@ -7,7 +7,7 @@ const GlobalNotificationSetting = require('./index');
 const GlobalNotificationSettingClass = GlobalNotificationSetting.class;
 const GlobalNotificationSettingSchema = GlobalNotificationSetting.schema;
 
-module.exports = function(crowi) {
+const factory = (crowi) => {
   GlobalNotificationSettingClass.crowi = crowi;
   GlobalNotificationSettingSchema.loadClass(GlobalNotificationSettingClass);
 
@@ -23,3 +23,5 @@ module.exports = function(crowi) {
 
   return GlobalNotificationSlackSettingModel;
 };
+
+export default factory;

+ 3 - 1
apps/app/src/server/models/bookmark.js

@@ -7,7 +7,7 @@ const uniqueValidator = require('mongoose-unique-validator');
 
 const ObjectId = mongoose.Schema.Types.ObjectId;
 
-module.exports = function(crowi) {
+const factory = (crowi) => {
   const bookmarkEvent = crowi.event('bookmark');
 
   let bookmarkSchema = null;
@@ -114,3 +114,5 @@ module.exports = function(crowi) {
 
   return mongoose.model('Bookmark', bookmarkSchema);
 };
+
+export default factory;

+ 2 - 7
apps/app/src/server/models/index.ts

@@ -1,16 +1,15 @@
 import GlobalNotificationSetting from './GlobalNotificationSetting';
 import GlobalNotificationMailSetting from './GlobalNotificationSetting/GlobalNotificationMailSetting';
 import GlobalNotificationSlackSetting from './GlobalNotificationSetting/GlobalNotificationSlackSetting';
+import Bookmark from './bookmark';
 import Page from './page';
-import PageTagRelation from './page-tag-relation';
 import SlackAppIntegration from './slack-app-integration';
 import User from './user';
 
 export const modelsDependsOnCrowi = {
   Page,
-  PageTagRelation,
   User,
-  Bookmark: require('./bookmark'),
+  Bookmark,
   GlobalNotificationSetting,
   GlobalNotificationMailSetting,
   GlobalNotificationSlackSetting,
@@ -26,7 +25,3 @@ export * as ShareLink from './share-link';
 export * as Tag from './tag';
 export * as UserGroup from './user-group';
 export * as PageTagRelation from './page-tag-relation';
-
-export * from './serializers';
-
-export * from './GlobalNotificationSetting';

+ 3 - 1
apps/app/src/server/models/slack-app-integration.js

@@ -53,8 +53,10 @@ class SlackAppIntegration {
 
 }
 
-module.exports = function(crowi) {
+const factory = (crowi) => {
   SlackAppIntegration.crowi = crowi;
   schema.loadClass(SlackAppIntegration);
   return mongoose.model('SlackAppIntegration', schema);
 };
+
+export default factory;

+ 3 - 1
apps/app/src/server/models/user.js

@@ -20,7 +20,7 @@ const ObjectId = mongoose.Schema.Types.ObjectId;
 
 const logger = loggerFactory('growi:models:user');
 
-module.exports = function(crowi) {
+const factory = (crowi) => {
   const STATUS_REGISTERED = 1;
   const STATUS_ACTIVE = 2;
   const STATUS_SUSPENDED = 3;
@@ -785,3 +785,5 @@ module.exports = function(crowi) {
 
   return mongoose.model('User', userSchema);
 };
+
+export default factory;

+ 1 - 1
apps/app/src/server/routes/apiv3/attachment.js

@@ -4,7 +4,7 @@ import autoReap from 'multer-autoreap';
 
 import { SupportedAction } from '~/interfaces/activity';
 import { AttachmentType } from '~/server/interfaces/attachment';
-import { Attachment } from '~/server/models';
+import { Attachment } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { generateAddActivityMiddleware } from '../../middlewares/add-activity';

+ 1 - 1
apps/app/src/server/routes/apiv3/customize-setting.js

@@ -9,7 +9,7 @@ import multer from 'multer';
 import { GrowiPlugin } from '~/features/growi-plugin/server/models';
 import { SupportedAction } from '~/interfaces/activity';
 import { AttachmentType } from '~/server/interfaces/attachment';
-import { Attachment } from '~/server/models';
+import { Attachment } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { generateAddActivityMiddleware } from '../../middlewares/add-activity';

+ 9 - 4
apps/app/src/server/routes/apiv3/invited.ts

@@ -1,16 +1,18 @@
-import express, { Request, Router } from 'express';
+import type { IUser } from '@growi/core';
+import type { Request, Router } from 'express';
+import express from 'express';
+import mongoose from 'mongoose';
 
-import Crowi from '../../crowi';
+import type Crowi from '../../crowi';
 import { invitedRules, invitedValidation } from '../../middlewares/invited-form-validator';
 
-import { ApiV3Response } from './interfaces/apiv3-response';
+import type { ApiV3Response } from './interfaces/apiv3-response';
 
 type InvitedFormRequest = Request & { form: any, user: any };
 
 module.exports = (crowi: Crowi): Router => {
   const applicationInstalled = require('../../middlewares/application-installed')(crowi);
   const debug = require('debug')('growi:routes:login');
-  const User = crowi.model('User');
   const router = express.Router();
 
   router.post('/', applicationInstalled, invitedRules(), invitedValidation, async(req: InvitedFormRequest, res: ApiV3Response) => {
@@ -22,6 +24,9 @@ module.exports = (crowi: Crowi): Router => {
       return res.apiv3Err(req.form.errors, 400);
     }
 
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    const User = mongoose.model<IUser, any>('User');
+
     const user = req.user;
     const invitedForm = req.form.invitedForm || {};
     const username = invitedForm.username;

+ 1 - 1
apps/app/src/server/routes/apiv3/notification-setting.js

@@ -1,7 +1,7 @@
 import { ErrorV3 } from '@growi/core/dist/models';
 
 import { SupportedAction } from '~/interfaces/activity';
-import { GlobalNotificationSettingType } from '~/server/models';
+import { GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
 import loggerFactory from '~/utils/logger';
 import { removeNullPropertyFromObject } from '~/utils/object-utils';
 

+ 5 - 6
apps/app/src/server/routes/apiv3/page-listing.ts

@@ -1,5 +1,5 @@
 import type {
-  IPageInfoForListing, IPageInfo,
+  IPageInfoForListing, IPageInfo, IPage,
 } from '@growi/core';
 import { getIdForRef, isIPageInfoForEntity } from '@growi/core';
 import { ErrorV3 } from '@growi/core/dist/models';
@@ -8,7 +8,6 @@ import express from 'express';
 import { query, oneOf } from 'express-validator';
 import mongoose from 'mongoose';
 
-
 import type { IPageGrantService } from '~/server/service/page-grant';
 import loggerFactory from '~/utils/logger';
 
@@ -65,7 +64,7 @@ const routerFactory = (crowi: Crowi): Router => {
 
 
   router.get('/root', accessTokenParser, loginRequired, async(req: AuthorizedRequest, res: ApiV3Response) => {
-    const Page: PageModel = crowi.model('Page');
+    const Page = mongoose.model<IPage, PageModel>('Page');
 
     let rootPage;
     try {
@@ -122,9 +121,9 @@ const routerFactory = (crowi: Crowi): Router => {
     const attachBookmarkCount: boolean = attachBookmarkCountParam === 'true';
     const attachShortBody: boolean = attachShortBodyParam === 'true';
 
-    const Page = mongoose.model('Page') as unknown as PageModel;
-    const Bookmark = crowi.model('Bookmark');
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+    const Page = mongoose.model<IPage, PageModel>('Page');
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    const Bookmark = mongoose.model<any, any>('Bookmark');
     const pageService = crowi.pageService;
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     const pageGrantService: IPageGrantService = crowi.pageGrantService!;

+ 2 - 3
apps/app/src/server/routes/apiv3/page/create-page.ts

@@ -16,11 +16,10 @@ import { subscribeRuleNames } from '~/interfaces/in-app-notification';
 import type { IOptionsForCreate } from '~/interfaces/page';
 import type Crowi from '~/server/crowi';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
-import {
-  GlobalNotificationSettingEvent, serializePageSecurely, serializeRevisionSecurely,
-} from '~/server/models';
+import { GlobalNotificationSettingEvent } from '~/server/models/GlobalNotificationSetting';
 import type { PageDocument, PageModel } from '~/server/models/page';
 import PageTagRelation from '~/server/models/page-tag-relation';
+import { serializePageSecurely, serializeRevisionSecurely } from '~/server/models/serializers';
 import { configManager } from '~/server/service/config-manager';
 import { getTranslation } from '~/server/service/i18next';
 import loggerFactory from '~/utils/logger';

+ 2 - 3
apps/app/src/server/routes/apiv3/page/update-page.ts

@@ -13,10 +13,9 @@ import { type IApiv3PageUpdateParams, PageUpdateErrorCode } from '~/interfaces/a
 import type { IOptionsForUpdate } from '~/interfaces/page';
 import type Crowi from '~/server/crowi';
 import { generateAddActivityMiddleware } from '~/server/middlewares/add-activity';
-import {
-  GlobalNotificationSettingEvent, serializePageSecurely, serializeRevisionSecurely, serializeUserSecurely,
-} from '~/server/models';
+import { GlobalNotificationSettingEvent } from '~/server/models/GlobalNotificationSetting';
 import type { PageDocument, PageModel } from '~/server/models/page';
+import { serializePageSecurely, serializeRevisionSecurely, serializeUserSecurely } from '~/server/models/serializers';
 import { preNotifyService } from '~/server/service/pre-notify';
 import { getYjsService } from '~/server/service/yjs';
 import { generalXssFilter } from '~/services/general-xss-filter';

+ 1 - 1
apps/app/src/server/routes/apiv3/pages/index.js

@@ -8,7 +8,7 @@ import { body, query } from 'express-validator';
 
 import { SupportedTargetModel, SupportedAction } from '~/interfaces/activity';
 import { subscribeRuleNames } from '~/interfaces/in-app-notification';
-import { GlobalNotificationSettingEvent } from '~/server/models';
+import { GlobalNotificationSettingEvent } from '~/server/models/GlobalNotificationSetting';
 import PageTagRelation from '~/server/models/page-tag-relation';
 import { preNotifyService } from '~/server/service/pre-notify';
 import loggerFactory from '~/utils/logger';

+ 1 - 3
apps/app/src/server/routes/attachment/api.js

@@ -1,11 +1,9 @@
-import { isCreatablePage, isUserPage } from '@growi/core/dist/utils/page-path-utils';
 
 import { SupportedAction } from '~/interfaces/activity';
 import { AttachmentType } from '~/server/interfaces/attachment';
 import loggerFactory from '~/utils/logger';
 
-import { Attachment, serializePageSecurely, serializeRevisionSecurely } from '../../models';
-
+import { Attachment } from '../../models/attachment';
 /* eslint-disable no-use-before-define */
 
 

+ 1 - 1
apps/app/src/server/routes/attachment/get-brand-logo.ts

@@ -9,7 +9,7 @@ import loggerFactory from '~/utils/logger';
 import type Crowi from '../../crowi';
 import { AttachmentType } from '../../interfaces/attachment';
 import { generateCertifyBrandLogoMiddleware } from '../../middlewares/certify-brand-logo';
-import { Attachment } from '../../models';
+import { Attachment } from '../../models/attachment';
 import ApiResponse from '../../util/apiResponse';
 
 import { getActionFactory } from './get';

+ 1 - 1
apps/app/src/server/routes/attachment/get.ts

@@ -17,7 +17,7 @@ import loggerFactory from '~/utils/logger';
 
 import type Crowi from '../../crowi';
 import { certifySharedPageAttachmentMiddleware } from '../../middlewares/certify-shared-page-attachment';
-import { Attachment, type IAttachmentDocument } from '../../models';
+import { Attachment, type IAttachmentDocument } from '../../models/attachment';
 import ApiResponse from '../../util/apiResponse';
 
 

+ 1 - 1
apps/app/src/server/routes/comment.js

@@ -3,7 +3,7 @@ import { Comment, CommentEvent, commentEvent } from '~/features/comment/server';
 import { SupportedAction, SupportedTargetModel, SupportedEventModel } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 
-import { GlobalNotificationSettingEvent } from '../models';
+import { GlobalNotificationSettingEvent } from '../models/GlobalNotificationSetting';
 import { preNotifyService } from '../service/pre-notify';
 
 /**

+ 4 - 3
apps/app/src/server/routes/ogp.ts

@@ -4,15 +4,16 @@ import path from 'path';
 import { DevidedPagePath } from '@growi/core/dist/models';
 // eslint-disable-next-line no-restricted-imports
 import axios from 'axios';
-import {
+import type {
   Request, Response, NextFunction,
 } from 'express';
-import { param, validationResult, ValidationError } from 'express-validator';
+import type { ValidationError } from 'express-validator';
+import { param, validationResult } from 'express-validator';
 
 import loggerFactory from '~/utils/logger';
 import { projectRoot } from '~/utils/project-dir-utils';
 
-import { Attachment } from '../models';
+import { Attachment } from '../models/attachment';
 import { convertStreamToBuffer } from '../util/stream';
 
 const logger = loggerFactory('growi:routes:ogp');

+ 1 - 1
apps/app/src/server/routes/page.js

@@ -3,7 +3,7 @@ import mongoose from 'mongoose';
 
 import loggerFactory from '~/utils/logger';
 
-import { GlobalNotificationSettingEvent } from '../models';
+import { GlobalNotificationSettingEvent } from '../models/GlobalNotificationSetting';
 import { PathAlreadyExistsError } from '../models/errors';
 import PageTagRelation from '../models/page-tag-relation';
 import UpdatePost from '../models/update-post';

+ 1 - 1
apps/app/src/server/service/attachment.js

@@ -1,7 +1,7 @@
 import loggerFactory from '~/utils/logger';
 
 import { AttachmentType } from '../interfaces/attachment';
-import { Attachment } from '../models';
+import { Attachment } from '../models/attachment';
 
 const fs = require('fs');
 

+ 1 - 1
apps/app/src/server/service/file-uploader/aws.ts

@@ -13,7 +13,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
 import urljoin from 'url-join';
 
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 8 - 5
apps/app/src/server/service/file-uploader/azure.ts

@@ -1,11 +1,14 @@
-import { ClientSecretCredential, TokenCredential } from '@azure/identity';
-import {
-  generateBlobSASQueryParameters,
-  BlobServiceClient,
+import type { TokenCredential } from '@azure/identity';
+import { ClientSecretCredential } from '@azure/identity';
+import type {
   BlobClient,
   BlockBlobClient,
   BlobDeleteOptions,
   ContainerClient,
+} from '@azure/storage-blob';
+import {
+  generateBlobSASQueryParameters,
+  BlobServiceClient,
   ContainerSASPermissions,
   SASProtocol,
   type BlobDeleteIfExistsResponse,
@@ -14,7 +17,7 @@ import {
 } from '@azure/storage-blob';
 
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 1 - 1
apps/app/src/server/service/file-uploader/file-uploader.ts

@@ -4,7 +4,7 @@ import type { Response } from 'express';
 
 import type { ICheckLimitResult } from '~/interfaces/attachment';
 import { type RespondOptions, ResponseMode } from '~/server/interfaces/attachment';
-import { Attachment, type IAttachmentDocument } from '~/server/models';
+import { Attachment, type IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 1 - 1
apps/app/src/server/service/file-uploader/gcs.ts

@@ -3,7 +3,7 @@ import urljoin from 'url-join';
 
 import type Crowi from '~/server/crowi';
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 1 - 1
apps/app/src/server/service/file-uploader/gridfs.ts

@@ -5,7 +5,7 @@ import mongoose from 'mongoose';
 import { createModel } from 'mongoose-gridfs';
 
 import type { RespondOptions } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 1 - 1
apps/app/src/server/service/file-uploader/local.ts

@@ -3,7 +3,7 @@ import { Readable } from 'stream';
 import type { Response } from 'express';
 
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { configManager } from '../config-manager';

+ 1 - 1
apps/app/src/server/service/file-uploader/utils/headers.ts

@@ -1,7 +1,7 @@
 import type { Response } from 'express';
 
 import type { ExpressHttpHeader, IContentHeaders } from '~/server/interfaces/attachment';
-import type { IAttachmentDocument } from '~/server/models';
+import type { IAttachmentDocument } from '~/server/models/attachment';
 
 
 export class ContentHeaders implements IContentHeaders {

+ 6 - 3
apps/app/src/server/service/g2g-transfer.ts

@@ -4,9 +4,10 @@ import { basename } from 'path';
 import type { Readable } from 'stream';
 
 // eslint-disable-next-line no-restricted-imports
+import type { IUser } from '@growi/core';
 import rawAxios, { type AxiosRequestConfig } from 'axios';
 import FormData from 'form-data';
-import { Types as MongooseTypes } from 'mongoose';
+import mongoose, { Types as MongooseTypes } from 'mongoose';
 
 import { G2G_PROGRESS_STATUS } from '~/interfaces/g2g-transfer';
 import GrowiArchiveImportOption from '~/models/admin/growi-archive-import-option';
@@ -19,7 +20,7 @@ import loggerFactory from '~/utils/logger';
 import { TransferKey } from '~/utils/vo/transfer-key';
 
 import type Crowi from '../crowi';
-import { Attachment } from '../models';
+import { Attachment } from '../models/attachment';
 import { G2GTransferError, G2GTransferErrorCode } from '../models/vo/g2g-transfer-error';
 
 import { configManager } from './config-manager';
@@ -257,7 +258,9 @@ export class G2GTransferPusherService implements Pusher {
       };
     }
 
-    const activeUserCount = await this.crowi.model('User').countActiveUsers();
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    const User = mongoose.model<IUser, any>('User');
+    const activeUserCount = await User.countActiveUsers();
     if ((destGROWIInfo.userUpperLimit ?? Infinity) < activeUserCount) {
       return {
         canTransfer: false,

+ 1 - 1
apps/app/src/server/service/global-notification/global-notification-mail.js

@@ -1,6 +1,6 @@
 import nodePath from 'path';
 
-import { GlobalNotificationSettingEvent, GlobalNotificationSettingType } from '~/server/models';
+import { GlobalNotificationSettingEvent, GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
 import { configManager } from '~/server/service/config-manager';
 import loggerFactory from '~/utils/logger';
 

+ 1 - 1
apps/app/src/server/service/global-notification/global-notification-slack.js

@@ -1,6 +1,6 @@
 import { pagePathUtils } from '@growi/core/dist/utils';
 
-import { GlobalNotificationSettingEvent, GlobalNotificationSettingType } from '~/server/models';
+import { GlobalNotificationSettingEvent, GlobalNotificationSettingType } from '~/server/models/GlobalNotificationSetting';
 import loggerFactory from '~/utils/logger';
 
 import {

+ 36 - 0
apps/app/src/server/service/playground-2.mongodb.js

@@ -0,0 +1,36 @@
+/* global use, db */
+// MongoDB Playground
+// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
+
+// The current database to use.
+use('growi');
+
+// Search for documents in the current collection.
+db.getCollection('yjs-writings')
+  .find(
+    {
+      // version: 'v1',
+      // docName: '646fd27beff95905ea491a2d',
+      // version: 'v1_sv',
+      // clock: 0,
+      metaKey: 'meta_updatedAt',
+      /*
+      * Filter
+      * fieldA: value or expression
+      */
+    },
+    {
+      /*
+      * Projection
+      * _id: 0, // exclude _id
+      * fieldA: 1 // include field
+      */
+    },
+  )
+  .sort({
+    /*
+    * fieldA: 1 // ascending
+    * fieldB: -1 // descending
+    */
+  });
+// .explain('executionStats');