Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectId does not work with new version of mongoose (5.12.8+) & workaround #83

Open
edshen17 opened this issue Nov 4, 2021 · 0 comments

Comments

@edshen17
Copy link

edshen17 commented Nov 4, 2021

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch ts-mongoose@0.0.24 for the project I'm working on.

Currently, my mongoose version is ^6.0.12.

Here is the diff that solved my problem:

diff --git a/node_modules/ts-mongoose/Type.d.ts b/node_modules/ts-mongoose/Type.d.ts
index a5a83f8..076b49d 100644
--- a/node_modules/ts-mongoose/Type.d.ts
+++ b/node_modules/ts-mongoose/Type.d.ts
@@ -1,12 +1,12 @@
 /// <reference path="plugin.d.ts" />
-import { Types } from 'mongoose';
+import { ObjectId, Types } from 'mongoose';
 import { Convert, EnumOrString, Extract, GetType, TypeOptions, GetSubDocument, ArrElement } from './types';
 export declare const Type: {
     number: <O extends TypeOptions<number>>(options?: O | undefined) => GetType<O, number>;
     boolean: <O_1 extends TypeOptions<boolean>>(options?: O_1 | undefined) => GetType<O_1, boolean>;
     date: <O_2 extends TypeOptions<Date>>(options?: O_2 | undefined) => GetType<O_2, Date>;
     mixed: <O_3 extends TypeOptions<any>>(options?: O_3 | undefined) => GetType<O_3, any>;
-    objectId: <O_4 extends TypeOptions<Types.ObjectId>>(options?: O_4 | undefined) => GetType<O_4, Types.ObjectId>;
+    objectId: <O_4 extends TypeOptions<Types.ObjectId>>(options?: O_4 | undefined) => Schema.Types.ObjectId;
     string: <O_5 extends Pick<import("mongoose").SchemaTypeOpts<string>, string | number> & Partial<Record<"required", boolean> & Record<"select", boolean>> & {
         enum?: readonly string[] | undefined;
     }>(options?: O_5 | undefined) => GetType<O_5, EnumOrString<O_5>>;

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant