generators/app/templates/server/lib/controllers/crud.controller.js
function (req, res) {
    var query = req.query;

    if (this.omit.length) {
      query = _.omit(query, this.omit);
    }

    query = this.model.find(query);

    if (this.lean) {
      query.lean();
    }

    if (this.select.length) {
      query.select(this.select.join(' '));
    }

    this.populateQuery(query, this.filterPopulations('index'));

    query.exec(function (err, documents) {
      if (err) {
        return res.handleError(err);
      }
      return res.ok(documents);
    });
  }
function (req, res) {
    var query = req.query;

    if (this.omit.length) {
      query = _.omit(query, this.omit);
    }

    query = this.model.find(query);

    if (this.lean) {
      query.lean();
    }

    if (this.select.length) {
      query.select(this.select.join(' '));
    }

    this.populateQuery(query, this.filterPopulations('index'));

    query.exec(function (err, documents) {
      if (err) {
        return res.handleError(err);
      }
      return res.ok(documents);
    });
  }
function ( req , res ) { var query = req . query ; if ( this . omit . length ) { query = _ . omit ( query , this . omit ) ; } query = this . model . find ( query ) ; if ( this . lean ) { query . lean ( ) ; } if ( this . select . length ) { query . select ( this . select . join ( ' ' ) ) ; } this . populateQuery ( query , this . filterPopulations ( 'index' ) ) ; query . exec ( function ( err , documents ) { if ( err ) { return res . handleError ( err ) ; } return res . ok ( documents ) ; } ) ; }
Get a list of documents. If a request query is passed it is used as the
query object for the find method.
@param {IncomingMessage} req - The request message object
@param {ServerResponse} res - The outgoing response object the result is set to
@returns {ServerResponse} Array of all documents for the {@link CrudController#model} model
or the empty Array if no documents have been found
Get a list of documents . If a request query is passed it is used as the query object for the find method .