lib/controllers/search.js
function search(req, res, next) {
  res.__apiMethod = 'search';

  buildQuery.call(this, req).exec(function (err, obj) {
    if (err) {
      var isCastError =
        (err.name === 'CastError') ||
        (err.message && err.message[0] === '$') ||
        (err.message === 'and needs an array')
      ;

      if (isCastError) return next(
        new ModelAPIError(400, err.message)
      );

      return next(err);
    }
    res.json(obj);
  });

}
function search(req, res, next) {
  res.__apiMethod = 'search';

  buildQuery.call(this, req).exec(function (err, obj) {
    if (err) {
      var isCastError =
        (err.name === 'CastError') ||
        (err.message && err.message[0] === '$') ||
        (err.message === 'and needs an array')
      ;

      if (isCastError) return next(
        new ModelAPIError(400, err.message)
      );

      return next(err);
    }
    res.json(obj);
  });

}
function search ( req , res , next ) { res . __apiMethod = 'search' ; buildQuery . call ( this , req ) . exec ( function ( err , obj ) { if ( err ) { var isCastError = ( err . name === 'CastError' ) || ( err . message && err . message [ 0 ] === '$' ) || ( err . message === 'and needs an array' ) ; if ( isCastError ) return next ( new ModelAPIError ( 400 , err . message ) ) ; return next ( err ) ; } res . json ( obj ) ; } ) ; }
search - Searches the objects in attached model collection

@param  {express.Request}  req        the http(s) request
@param  {express.Response} res        the http(s) response
@param  {Function}         next       the callback should be called if controller fails

@memberof ModelAPIRouter
search - Searches the objects in attached model collection