baucis-decorator-reserved
v1.0.1
Published
Prevents clients from setting or updating properties with `reserved` option enabled.
Downloads
9
Maintainers
Readme
baucis-decorator-reserved
Prevents clients from setting or updating properties with reserved
option enabled.
Install
npm install baucis-decorators baucis-decorator-reserved --save
Usage
Add the decorator and it will add the functionality to any properties containing a reserved
field set to true
.
Example
controllers/Resource.js
var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;
var ResourceProps = {};
ResourceProps.created = {
type: Date,
default: Date.now,
required: true,
reserved: true
};
var ResourceSchema = new Schema(ResourceProps);
var ResourceModel = mongoose.model('Resource', ResourceSchema);
var ResourceController = baucis.rest('Resource');
var decorators = require('baucis-decorators');
decorators.add.call(ResourceController, [
'baucis-decorator-reserved'
]);
/**
* Expose controller.
*/
module.exports = ResourceController;