baucis-decorator-valid-object-id

1.0.1 • Public • Published

baucis-decorator-valid-object-id

Ensures valid ObjectIds where applicable.

Install

npm install baucis-decorators baucis-decorator-valid-object-id --save

Usage

Just add the decorator and it should work.

Example

controllers/Resource.js

var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;

var ResourceProps = {};

ResourceProps.modifiedBy = {
  type: ObjectId,
  ref: 'User'
};

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-valid-object-id'
]);

/**
 * Expose controller.
 */
module.exports = ResourceController;

Package Sidebar

Install

npm i baucis-decorator-valid-object-id

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • timbur