-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Document does not type non-default timestamp property names #13215
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
We'll add support for this in the future. But, in the meantime, I recommend you add const MySchema = new Schema({
username: String,
date_joined: Date,
}, {
timestamps: {
createdAt: "date_joined",
updatedAt: false,
},
}); |
The way I added my timestamps is as follows: const MySchema = new Schema({ |
vkarpov15
added a commit
that referenced
this issue
Aug 7, 2024
fix: support schema type inference based on schema options timestamps as well
This was referenced Sep 4, 2024
This was referenced Sep 19, 2024
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Prerequisites
Mongoose version
6.8.0, 7.0.3
Node.js version
16.17.0
MongoDB server version
5.0.14
Typescript version (if applicable)
4.8.4
Description
Builds on earlier issue #12069 where
Document
andInferSchemaType
does not infer timestamp fields into Typescript types.Renamed timestamp fields are not extracted using
Document
andInferSchemaType
.Steps to Reproduce
Expected Behavior
We expect
MyType
to be:We get:
Note how not even
createdAt
is on the type. Looking at the actual Document, we will see a type that looks like our expected type (with username, date_joined, and no updatedAt field).The text was updated successfully, but these errors were encountered: