generators/app/templates/server/lib/controllers/param.controller.js
function ParamController(model, idName, paramName, router) {
  var modelName = model.modelName.toLowerCase();

  // make idName and paramName arguments optional (v0.1.1)
  if (typeof idName === 'function') {
    router = idName;
    idName = modelName + 'Id';
  }

  if (typeof paramName === 'function') {
    router = paramName;
    paramName = modelName + 'Param';
  }

  // call super constructor
  CrudController.call(this, model, idName);

  // only set param if it is set, will default to 'id'
  if (!paramName) {
    paramName = modelName + 'Param';
  }

  this.paramName = String(paramName);
  this.paramString = ':' + this.paramName;

  // register param name route parameter
  router.param(this.paramName, this.registerRequestParameter);
}
function ParamController(model, idName, paramName, router) {
  var modelName = model.modelName.toLowerCase();

  // make idName and paramName arguments optional (v0.1.1)
  if (typeof idName === 'function') {
    router = idName;
    idName = modelName + 'Id';
  }

  if (typeof paramName === 'function') {
    router = paramName;
    paramName = modelName + 'Param';
  }

  // call super constructor
  CrudController.call(this, model, idName);

  // only set param if it is set, will default to 'id'
  if (!paramName) {
    paramName = modelName + 'Param';
  }

  this.paramName = String(paramName);
  this.paramString = ':' + this.paramName;

  // register param name route parameter
  router.param(this.paramName, this.registerRequestParameter);
}
function ParamController ( model , idName , paramName , router ) { var modelName = model . modelName . toLowerCase ( ) ; // make idName and paramName arguments optional (v0.1.1) if ( typeof idName === 'function' ) { router = idName ; idName = modelName + 'Id' ; } if ( typeof paramName === 'function' ) { router = paramName ; paramName = modelName + 'Param' ; } // call super constructor CrudController . call ( this , model , idName ) ; // only set param if it is set, will default to 'id' if ( ! paramName ) { paramName = modelName + 'Param' ; } this . paramName = String ( paramName ) ; this . paramString = ':' + this . paramName ; // register param name route parameter router . param ( this . paramName , this . registerRequestParameter ) ; }
Constructor function for ParamController.
@classdesc Controller for basic CRUD operations on mongoose models.
Using a route parameter object (request property) if possible.
The parameter name is passed as the third argument.
@constructor
@inherits CrudController
@param {Object} model - The mongoose model to operate on
@param {String} [idName] - The name of the id request parameter to use,
defaults to the lowercase model name with 'Id' appended.
@param {String} [paramName] - The name of the request property to use,
defaults to the lowercase model name with 'Param' appended.
@param {Object} router - The express router to attach the param function to
Constructor function for ParamController .