title: Deleting data from associated tables using knex.js
body: <p>I want to delete from an articles table using knex by article_id. This already exists in comments table as a foreign key. </p>
  
  <p>How can I test that data has been deleted and how can I send that to the user. </p>
  
  <p>I decided to approach this by writing a function to delete from both functions with a .then. Does this look like I am on the right lines?</p>
  
  <pre><code>exports.deleteArticleById = function (req, res, next) {
    const { article_id } = req.params;
    return connection('comments')
      .where('comments.article_id', article_id)
      .del()
      .returning('*')
      .then((deleted) =&gt; {
        console.log(deleted);
        return connection('articles')
          .where('articles.article_id', article_id)
          .del()
          .returning('*');
      })
      .then((article) =&gt; {
        console.log(article);
        return res.status(204).send('article deleted');
      })
      .catch(err =&gt; next(err));
  };
  </code></pre>
  
  <p>At the moment I am getting the correct data with the logs but I am getting a status 500 but I think I need to be trying to get a 204? </p>
  
  <p>Any help would be much appreciated. </p>