MangoModel-Security provides some simple security utility methods for the MangoModel MongoDB wrapper.
To install, use NPM:
npm install mangomodel-security
To add the MongoModel-Security functionality to a MangoModel model, do the following:
var MangoModel =MangoModelSecurity =ExampleModel = MangoModel;ExampleModel;
Once this has been done, you can call the utility methods on the MangoModel object. Ie:
var record = name: 'John Doe' description: 'A regular guy' secret_stuff: 'Likes brussel sprouts';// Return a copy of the record with fields a user should seeExampleModel; // Return name and description// Get a copy of the record with only fields permissible by a user updatedExampleModel; // Only updates nameExampleModel; // Update all