-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
toObject
minimization not working with getters
#1607
Comments
Looking into this |
This is something we'd like to support. Try and get it in a 3.7.x release |
I experimented with fixing this, added a test to You can see the changes in my branch: https://github.com/JedWatson/mongoose/commits/master Mainly adding the following to
I'm not happy with the performance of this as a solution (it's a bit of a sledgehammer), but if somebody could confirm that this is the expected behaviour, I'll see if I can work out how to fix |
After cleaning up the code (so that I'm using an external function instead of creating it in |
I played i bit with
toObject
method and found, thatminimize: true
flag is being ignored whengetters: true
is set:It's not a problem for top-level fields, because
JSON
serialization removes such fields. Butnested
field becomes an empty object, which is not what I want to send to the client:It's not only about the amount of data I'm sending. For most client side frameworks
{}
means that my document has anested
sub-document, which is not true.The text was updated successfully, but these errors were encountered: