lib/mock/query-collection.js
function queryCollection (req, res, next, dataStore) {
  dataStore.getCollection(req.path, (err, resources) => {
    if (!err) {
      resources = filter(resources, req);

      if (resources.length === 0) {
        // There is no data, so use the current date/time as the "last-modified" header
        res.swagger.lastModified = new Date();

        // Use the default/example value, if there is one
        if (res.swagger.schema) {
          resources = res.swagger.schema.default || res.swagger.schema.example || [];
        }
      }
      else {
        // Determine the max "modifiedOn" date of the remaining items
        res.swagger.lastModified = _.maxBy(resources, "modifiedOn").modifiedOn;

        // Extract the "data" of each Resource
        resources = _.map(resources, "data");
      }

      // Set the response body (unless it's already been set by other middleware)
      res.body = res.body || resources;
    }

    next(err);
  });
}
function queryCollection (req, res, next, dataStore) {
  dataStore.getCollection(req.path, (err, resources) => {
    if (!err) {
      resources = filter(resources, req);

      if (resources.length === 0) {
        // There is no data, so use the current date/time as the "last-modified" header
        res.swagger.lastModified = new Date();

        // Use the default/example value, if there is one
        if (res.swagger.schema) {
          resources = res.swagger.schema.default || res.swagger.schema.example || [];
        }
      }
      else {
        // Determine the max "modifiedOn" date of the remaining items
        res.swagger.lastModified = _.maxBy(resources, "modifiedOn").modifiedOn;

        // Extract the "data" of each Resource
        resources = _.map(resources, "data");
      }

      // Set the response body (unless it's already been set by other middleware)
      res.body = res.body || resources;
    }

    next(err);
  });
}
function queryCollection ( req , res , next , dataStore ) { dataStore . getCollection ( req . path , ( err , resources ) => { if ( ! err ) { resources = filter ( resources , req ) ; if ( resources . length === 0 ) { // There is no data, so use the current date/time as the "last-modified" header res . swagger . lastModified = new Date ( ) ; // Use the default/example value, if there is one if ( res . swagger . schema ) { resources = res . swagger . schema . default || res . swagger . schema . example || [ ] ; } } else { // Determine the max "modifiedOn" date of the remaining items res . swagger . lastModified = _ . maxBy ( resources , "modifiedOn" ) . modifiedOn ; // Extract the "data" of each Resource resources = _ . map ( resources , "data" ) ; } // Set the response body (unless it's already been set by other middleware) res . body = res . body || resources ; } next ( err ) ; } ) ; }
Returns an array of all resources in the collection.
If there are no resources, then an empty array is returned.  No 404 error is thrown.

If the Swagger API includes "query" parameters, they can be used to filter the results.
Deep property names are allowed (e.g. "?address.city=New+York").
Query string params that are not defined in the Swagger API are ignored.

@param   {Request}   req
@param   {Response}  res
@param   {function}  next
@param   {DataStore} dataStore
Returns an array of all resources in the collection . If there are no resources then an empty array is returned . No 404 error is thrown .