Express multiple delete routes
<p>I am using the MEAN stack with sequelize. I have two cases where I want to delete records from a table:</p>

<p>1) delete a single record using an given id.</p>

<p>2) delete all records where some condition is met (all records that share a projectId). For this to work I am trying to set up two routes to handle each case.</p>

<p>Client side service (case 1):</p>

<pre><code>  this.deleteCampaign = function(id) {
    return $http.delete(campaignBaseUrl + id);
  };
</code></pre>

<p>Client side service (case 2):</p>

<pre><code>  this.deleteMultipleCampaigns = function(projectID) {
    return $http.delete(campaignBaseUrl+ 'foo/' + projectID);
  };
</code></pre>

<p>Server side routes:</p>

<pre><code>// I want case 1 to access this route (working)
router.delete('/:id', controller.destroy);
// I want case 2 to access this route (not working)
router.delete('/foo/:projectID', controller.destroyMultiple);
</code></pre>

<p><strong>UPDATE</strong> 
Server side controllers:</p>

<pre><code>// Deletes multiple Campaign from the DB
// for a give project ID
export function destroyMultiple(req, res) {
  console.log('req.params:');
  console.log(req.params); // { projectID: '7' }
  Campaign.findAll({
    where: {
      projectId: req.params.projectID
    }
  })
    .then(handleEntityNotFound(res))
    .then(removeEntity(res))
    .catch(handleError(res));
}

// Deletes a single Campaign from the DB
export function destroy(req, res) {
  console.log('destroySingle:');
  Campaign.find({
    where: {
      _id: req.params.id
    }
  })
    .then(handleEntityNotFound(res))
    .then(removeEntity(res))
    .catch(handleError(res));
}
</code></pre>

<p><strong>UPDATE 2</strong></p>

<p>Server side controller cont...</p>

<pre><code>function removeEntity(res) {
  return function(entity) {
    if (entity) {
      return entity.destroy()
        .then(() =&gt; {
          res.status(204).end();
        });
    }
  };
}
</code></pre>

<p>When I run case2 from the client I get this error:
<code>DELETE /api/campaigns/foo/7 500</code>
and
<code>{"name":"SequelizeDatabaseError","message":"invalid input syntax for integer: \"foo\"","parent":</code></p>