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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: add JSONSerialized helper that can convert HydratedDocument to JSON output type #14981

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14451

Summary

Right now it is hard to get the type of the JSON serialized document from a Mongoose document and schema. This PR adds a JSONSerialized type helper which transforms Mongoose subdocs into POJOs, ObjectIds into strings, Dates into strings, and Maps into POJOs. That should cover most cases.

Examples

@vkarpov15 vkarpov15 added this to the 8.7.3 milestone Oct 23, 2024
types/index.d.ts Show resolved Hide resolved
test/types/schema.test.ts Outdated Show resolved Hide resolved
@vkarpov15 vkarpov15 merged commit 6ab97f2 into master Oct 25, 2024
32 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14451 branch October 26, 2024 08:44
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

Successfully merging this pull request may close these issues.

2 participants