Просмотр исходного кода

replace mongoose.Type.ObjectId with bson-objectid

Yuki Takei 3 лет назад
Родитель
Сommit
b27251fdf4

+ 4 - 3
packages/app/src/interfaces/in-app-notification.ts

@@ -1,6 +1,7 @@
-import { Types } from 'mongoose';
-import { IUser } from './user';
+import ObjectId from 'bson-objectid';
+
 import { IPage } from './page';
+import { IUser } from './user';
 
 export enum InAppNotificationStatuses {
   STATUS_UNREAD = 'UNREAD',
@@ -55,6 +56,6 @@ export interface ISubscribeRule {
   isEnabled: boolean;
 }
 export interface IInAppNotificationSettings {
-  userId: Types.ObjectId;
+  userId: ObjectId | string;
   subscribeRules: ISubscribeRule[];
 }

+ 2 - 2
packages/app/src/server/interfaces/mongoose-utils.ts

@@ -1,3 +1,3 @@
-import mongoose from 'mongoose';
+import ObjectId from 'bson-objectid';
 
-export type ObjectIdLike = mongoose.Types.ObjectId | string;
+export type ObjectIdLike = ObjectId | string;

+ 2 - 2
packages/core/src/utils/page-path-utils.ts

@@ -1,7 +1,7 @@
 import nodePath from 'path';
 
+import ObjectId from 'bson-objectid';
 import escapeStringRegexp from 'escape-string-regexp';
-import { isValidObjectId } from 'mongoose';
 
 
 import { addTrailingSlash } from './path-utils';
@@ -28,7 +28,7 @@ export const isUsersTopPage = (path: string): boolean => {
  */
 export const isPermalink = (path: string): boolean => {
   const pageIdStr = path.substring(1);
-  return isValidObjectId(pageIdStr);
+  return ObjectId.isValid(pageIdStr);
 };
 
 /**