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

Fix bug not remove child private field #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

taina0407
Copy link
Contributor

@taina0407 taina0407 commented Sep 22, 2020

Fixing bug in case that private field in child field.

For example:

const thisSchema = new Schema({
  parent: {
    child: {
      type: [String],
      private: true,
    }
  },
}, options);

When calling .toJSON(), child still appear because current removePrivatePaths trying to access ret['parent.child'] instead of ret.parent.child

@adamreisnz
Copy link
Owner

You need to make child it's own schema, then you can use private: true correctly.

@adamreisnz adamreisnz closed this Sep 22, 2020
@taina0407
Copy link
Contributor Author

While mongoose still allow user to create child documents without schema, I think the plugin should also support it.
Or at least mention this on README.
Thanks

@adamreisnz
Copy link
Owner

Can you make a fix for it that doesn't introduce another dependency?

@adamreisnz adamreisnz reopened this Sep 22, 2020
@adamreisnz
Copy link
Owner

Looks like you have made changes to your own fork of this package and you are merging in unnecessary changes with this PR. You can clean that up if you want and leave only the fixes in, otherwise I'll close it without merging.

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