Closed bisubus closed 7 years ago
Good idea. I've implemented the feature and added/adjusted test cases. Could you try it out? Then I'll merge and publish to npm.
https://github.com/mblarsen/mongoose-hidden/tree/feature-hidden
Thanks for the quick response, works like a charm! Stumbled across a couple of issues on the way.
Merged and published
The suggestion is to introduce
hidden
option in addition todefaultHidden
.defaultHidden
option overrides previously defined defaults. This may not be always desired, because it requires to redefine hidden properties that could be otherwise inherited from default configuration.From my own experience, the models may show
_id
or hide timestamps, but__v
never needs to be exposed, so it is just redundant to mention it every time.It would be generally easier to manage hidden properties in additive manner (
Object.assign
),