title: knex promises - how to wait while two funcions finish their work
body: <p>How to add code that will run only when both processes are completed?</p>
  
  <pre><code>normalise1();
  normalise2();
  
  function normalise1() {
      return knex("ingredients")
          .select("name", "id")
          .map(function (ingredient) {            
              var normalised_name = common.normalise(ingredient.name);
              knex('ingredients').where('id', ingredient.id).update({ name_normalised: normalised_name }).then();
          });
  };
  
  function normalise2() {
      return knex("synonyms")
          .select("synon_name as name", "id")
          .map(function (ingredient) {            
              var normalised_name = common.normalise(ingredient.name);
              knex('synonyms').where('id', ingredient.id).update({ synon_name_normalised: normalised_name }).then();
          });
  };
  </code></pre>
  
  <p>I tried something like in different ways</p>
  
  <pre><code>Promise.all([normalise1(), normalise2()])
      .then(() =&gt; console.log('Done'));
  </code></pre>
  
  <p>but it didn't work. 
  Basically console.log('Done') appears before all process is done. I believe that this is because of missing Promise part inside functions, but I cannot figure out exactly how.</p>