Mongoose Model Update
Mongoose plugin providing a Model method for simple, filtered patch-style updates
Setup
Install
npm install --save mongoose-model-update
Require this alongside your router-
;// Or, for ES5-// var update = require('mongoose-model-update');
Usage
When registering the Mongoose plugin, you can optionally specify allowed fields
at the Model-level to be used as default params in Model.methods.update()
.
Model;
You can specify permitted fields to update in the 2nd argument. If no fields are provided and default params aren't set at the Model-level, then all fields will be available to update.
user
Use cases
At AutoLotto, we use this for PATCH API updates (RESTfully speaking). Ex-
{ // ... requser; // ...}