title: how to check if any of given queries return any result in knex
body: <p>I have two queries:</p>
  
  <p>a) <code>select id from ingredietns where name = my_param;</code></p>
  
  <p>b) <code>select word_id from synonyms where name = my_param;</code></p>
  
  <p>Both return 0 or 1 row. I can also add <code>limit 1</code> if needed (or in knex <code>first()</code>).</p>
  
  <p>I can translate each into knex like this:</p>
  
  <pre><code>knex("ingredients").select('id').where('name', my_param) //do we need first()?
  
  knex("synonyms").select('word_id').where('name', my_param) //do we need first()?
  </code></pre>
  
  <p>I need function called "<code>ingredientGetOrCreate(my_param)</code>". This function would </p>
  
  <p>a) check if any of above queries return result
  b) if any of these return, then return ingredients.id or synonyms.word_id - only one could be returned 
  c) if record doesn't eixst in any of tables, I need to do knex inesrt aand return newly added id from function</p>
  
  <p>d) later I am not sure I also understand how to call this newly create function.
  Function <code>ingredientGetOrCreate</code> would be used later as seperate function or in the following scenario (like "loop") that doesn't work for me either:</p>
  
  <pre><code>knex("products") // for each product
      .select("id", "name")
      .map(function (row) {
          var descriptionSplitByCommas = row.desc.split(",");
          Promise.all(descriptionSplitByCommas
              .map(function (my_param) {
                  // here it comes - call method for each param and do insert
                  ingredientGetOrCreate(my_param)
                    .then(function (id_of_ingredient) {
                            knex('ingredients_products').insert({ id_of_ingredient });                      
  
                    });
           ...
  </code></pre>
  
  <p>I am stuck with <code>knex</code> and <code>Promise</code> queries because of asynchronouse part. Any clues, please?
  I though I can somehow use <code>Promise.all</code> or <code>Promise.some</code> to call both queries.</p>
  
  <p>P.S. This is my first day with nodejs, Promise and knex.</p>