-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InferSchemaType generates Schema.Types.ObjectId instead of the Types.ObjectId we want #12002
Comments
@keysking Thanks for reporting this issue. |
My pleasure😁. |
apparently encountered with similar problem but in my case the field is array of refs:
the inferred type is |
Any fix that you found? I'm running into the same issue. |
Nope, I just used type casting to force mongoose.Types.ObjectId[] |
I ended up just creating the schema manually instead of using InferSchemaType to avoid the bug. |
Prerequisites
Mongoose version
6.4.1
Node.js version
18.*
MongoDB server version
5.x
Description
I learned from the documentation that when a Schema has a field whose type is Schema.Types.ObjectId, the corresponding Typescript type should be Types.ObjectId.
However, when I use InferSchemaType to generate the type, the type it generated for me is Schema.Types.ObjectId.
This prevents me from using the new Types.ObjectId () to pass into my field.
Steps to Reproduce
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: