-
Notifications
You must be signed in to change notification settings - Fork 54
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
Populate silently fails for cached documents unless lean() is set #17
Comments
I've tracked this back to Also, it appears to use |
hhmm, this could be tricky. I'm thinking I can probably check the query and determine which fields should be I'll have to play around with it a bit. |
I started looking into it, and sortof came up with a workaround (but its very hacky). I added a virtual to each collection, I'll tidy up the code a bit, and post it. Unfortunately, I wasn't able to support populated arrays without reimplementing mongooses dot-notation resolver. The approach of hydrating each child document isn't ideal, and is only required if you want to retain the ability to use the child's methods/virtuals. Potentially, a better middle ground could be monkeypatching |
@0x62 are you still posting your code some time? :) thanks |
Closing this due to inactivity. If anyone needs this functionality, for the time being I would recommend running your query as |
If using
.populate()
, you must set.lean()
, or fields will not be populated.Without
.lean()
:With
.lean()
:Is there any reason why there is no support for caching populated fields without
lean
?The text was updated successfully, but these errors were encountered: