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

what is `defaults` #4

Closed enVolt closed 8 years ago

enVolt commented 8 years ago

I still don't understand what is defaults in require statement.

mblarsen commented 8 years ago

The idea is that you can pass in default settings that is true for all the schemas you attach the plugin to.

var mongooseHidden = require("mongoose-hidden")({ defaultHidden: { password: true } });

In this case if a schema has a password defined it will now be hidden. You don't have to specify on the schema that password has the hidden property.

enVolt commented 8 years ago

It's a little confusing, you should update with an example, when I used it I've no idea what is default, is it an object or string or what, if object then what are keys . so . and . so .

mblarsen commented 8 years ago

True that. Until then read the code.