Nefarious Pomegranate Magnate
Miss any of our Open RFC calls?Watch the recordings here! »

baucis-decorator-reserved

1.0.1 • Public • Published

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;

Install

npm i baucis-decorator-reserved

DownloadsWeekly Downloads

4

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar