lib/mock/query-collection.js
function deleteCollection (req, res, next, dataStore) {
  dataStore.getCollection(req.path, (err, resources) => {
    if (err) {
      next(err);
    }
    else {
      // Determine which resources to delete, based on query params
      let resourcesToDelete = filter(resources, req);

      if (resourcesToDelete.length === 0) {
        sendResponse(null, []);
      }
      else if (resourcesToDelete.length === resources.length) {
        // Delete the whole collection
        dataStore.deleteCollection(req.path, sendResponse);
      }
      else {
        // Only delete the matching resources
        dataStore.delete(resourcesToDelete, sendResponse);
      }
    }
  });

  // Responds with the deleted resources
  function sendResponse (err, resources) {
    // Extract the "data" of each Resource
    resources = _.map(resources, "data");

    // Use the current date/time as the "last-modified" header
    res.swagger.lastModified = new Date();

    // Set the response body (unless it's already been set by other middleware)
    if (err || res.body) {
      next(err);
    }
    else if (!res.swagger.isCollection) {
      // Response body is a single value, so only return the first item in the collection
      res.body = _.first(resources);
      next();
    }
    else {
      // Response body is the resource that was created/update/deleted
      res.body = resources;
      next();
    }
  }
}
function deleteCollection (req, res, next, dataStore) {
  dataStore.getCollection(req.path, (err, resources) => {
    if (err) {
      next(err);
    }
    else {
      // Determine which resources to delete, based on query params
      let resourcesToDelete = filter(resources, req);

      if (resourcesToDelete.length === 0) {
        sendResponse(null, []);
      }
      else if (resourcesToDelete.length === resources.length) {
        // Delete the whole collection
        dataStore.deleteCollection(req.path, sendResponse);
      }
      else {
        // Only delete the matching resources
        dataStore.delete(resourcesToDelete, sendResponse);
      }
    }
  });

  // Responds with the deleted resources
  function sendResponse (err, resources) {
    // Extract the "data" of each Resource
    resources = _.map(resources, "data");

    // Use the current date/time as the "last-modified" header
    res.swagger.lastModified = new Date();

    // Set the response body (unless it's already been set by other middleware)
    if (err || res.body) {
      next(err);
    }
    else if (!res.swagger.isCollection) {
      // Response body is a single value, so only return the first item in the collection
      res.body = _.first(resources);
      next();
    }
    else {
      // Response body is the resource that was created/update/deleted
      res.body = resources;
      next();
    }
  }
}
function deleteCollection ( req , res , next , dataStore ) { dataStore . getCollection ( req . path , ( err , resources ) => { if ( err ) { next ( err ) ; } else { // Determine which resources to delete, based on query params let resourcesToDelete = filter ( resources , req ) ; if ( resourcesToDelete . length === 0 ) { sendResponse ( null , [ ] ) ; } else if ( resourcesToDelete . length === resources . length ) { // Delete the whole collection dataStore . deleteCollection ( req . path , sendResponse ) ; } else { // Only delete the matching resources dataStore . delete ( resourcesToDelete , sendResponse ) ; } } } ) ; // Responds with the deleted resources function sendResponse ( err , resources ) { // Extract the "data" of each Resource resources = _ . map ( resources , "data" ) ; // Use the current date/time as the "last-modified" header res . swagger . lastModified = new Date ( ) ; // Set the response body (unless it's already been set by other middleware) if ( err || res . body ) { next ( err ) ; } else if ( ! res . swagger . isCollection ) { // Response body is a single value, so only return the first item in the collection res . body = _ . first ( resources ) ; next ( ) ; } else { // Response body is the resource that was created/update/deleted res . body = resources ; next ( ) ; } } }
Deletes all resources in the collection.
If there are no resources, then nothing happens.  No error is thrown.

If the Swagger API includes "query" parameters, they can be used to filter what gets deleted.
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
Deletes all resources in the collection . If there are no resources then nothing happens . No error is thrown .