mblarsen / mongoose-hidden

A Mongoose schema plugin for filtering properties you usually do not want to sent client-side like passwords and IDs.
MIT License
89 stars 19 forks source link

Do not create undefined versions of properties not present in origina… #50

Closed proswdev closed 6 years ago

proswdev commented 6 years ago

Version 1.5 is not compatible with 1.4. It erroneously adds properties with undefined value for paths not present in original transformed object.

Example: with schema where fields are optional { field1: Number, field2: String, field3: String}) document before transform { field1: 123, field3: 'abc' } becomes after transform by mongoose-hidden { field1: 123, field2: undefined, field3: 'abc' }

The pull request includes a fix for this

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling b02f4fcb807b5cef3376ee6f7c2f6489ca157c59 on proswdev:master into 56d51d73d3fdb0726801129e12631a9d017d26c2 on mblarsen:master.

mblarsen commented 6 years ago

Good catch. Leaving a few comments on the commit.

mblarsen commented 6 years ago

Please make the style changes and remove the comment. Or let me know if I should do it after the merge.

mblarsen commented 6 years ago

Hmm, what if the value in the transform was actually undefined could that be the case? Should we really be checking if the initial transform has that key or not?

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 17d0f6c4dde0937b33cf652d26761c8f3db18b2a on proswdev:master into 56d51d73d3fdb0726801129e12631a9d017d26c2 on mblarsen:master.

mblarsen commented 6 years ago

@proswdev thanks for the contribution. I publish the changes as version 1.5.1

mblarsen commented 4 years ago

@all-contributors add @proswdev for bug, test, code

allcontributors[bot] commented 4 years ago

@mblarsen

I've put up a pull request to add @proswdev! :tada: