lib/mock/edit-collection.js
function mergeCollection (req, res, next, dataStore) {
  let collection = req.path;
  let resources = createResources(req);

  // Set the "Location" HTTP header.
  // If the operation allows saving multiple resources, then use the collection path.
  // If the operation only saves a single resource, then use the resource's path.
  res.swagger.location = _.isArray(req.body) ? collection : resources[0].toString();

  // Save/Update the resources
  util.debug("Saving data at %s", res.swagger.location);
  dataStore.save(resources, sendResponse(req, res, next, dataStore));
}
function mergeCollection (req, res, next, dataStore) {
  let collection = req.path;
  let resources = createResources(req);

  // Set the "Location" HTTP header.
  // If the operation allows saving multiple resources, then use the collection path.
  // If the operation only saves a single resource, then use the resource's path.
  res.swagger.location = _.isArray(req.body) ? collection : resources[0].toString();

  // Save/Update the resources
  util.debug("Saving data at %s", res.swagger.location);
  dataStore.save(resources, sendResponse(req, res, next, dataStore));
}
function mergeCollection ( req , res , next , dataStore ) { let collection = req . path ; let resources = createResources ( req ) ; // Set the "Location" HTTP header. // If the operation allows saving multiple resources, then use the collection path. // If the operation only saves a single resource, then use the resource's path. res . swagger . location = _ . isArray ( req . body ) ? collection : resources [ 0 ] . toString ( ) ; // Save/Update the resources util . debug ( "Saving data at %s" , res . swagger . location ) ; dataStore . save ( resources , sendResponse ( req , res , next , dataStore ) ) ; }
Adds one or more REST resources to the collection, or updates them if they already exist.
A unique URL is generated for each new resource, based on the schema definition in the Swagger API,
and this URL is used to determine whether a given resource is being created or updated.

For example, if you POST the data {id: 123, name: 'John Doe'} to /api/users,
then the "id" property will be used to construct the new REST URL: /api/users/123

Similarly, if you POST the data {name: 'John Doe', age: 42} to /api/users,
then the "name" property will be used to construct the new URL: /api/users/John%20Doe

If the data doesn't contain any properties that seem like unique IDs, then a unique ID is generated,
which means new resources will always be created, and never updated.

@param   {Request}   req
@param   {Response}  res
@param   {function}  next
@param   {DataStore} dataStore
Adds one or more REST resources to the collection or updates them if they already exist . A unique URL is generated for each new resource based on the schema definition in the Swagger API and this URL is used to determine whether a given resource is being created or updated .