title: node.js - determine when per-row asynchronous function is not called due to there being no rows
body: <p>I'm trying to write code that will be executed if an SQLite query won't return results. However, the async nature of Node.js makes this difficult. I don't know if I can write code inside the callback function, because when I test with inputs that will cause empty results, nothing happens.</p>
  
  <p>I'm doing</p>
  
  <pre><code> db.each("SELECT pid, collection , photo FROM photos WHERE collection = '"+collection_id+"' AND pid = '"+photo_id+"' ", function(err, row) {
        console.log("PHOTO FOUND");
  
  //code inside the callback function
  
    });
      //code I want
  </code></pre>
  
  <p>Specifically, I want to render something general, in case the user requests something that is not in the db
  What should I do?</p>