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

Properly serialize/deserialize mongoose documents to/from cache #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

doronrk
Copy link

@doronrk doronrk commented Sep 19, 2022

@lorensr How does this look to you? This is fully backwards compatible. Code expecting mongoose documents to be returned from the find... methods will not break. toObject is called only before serializing to the cache, not on the return value. When a document is deserialized from the cache, mongoose.Model.hydrate is called on the result as well because the API expects a mongoose document in this case.

Happy to address any feedback in the approach, let me know.

@doronrk
Copy link
Author

doronrk commented Sep 26, 2022

@lorensr Just following up here. I can add unit tests and make changes, but wanted to first get your input on the high level approach before spending additional time.

@lorensr
Copy link
Member

lorensr commented Oct 8, 2022

Hey @doronrk, sorry for the wait—code looks good, tests sound good ☺️

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.

None yet

2 participants