title: How to hint an asynchronous operation with a JavaScript promise?
body: <p>For learning purposes, I want to show how promises can help solving time dependencies of database operations in JavaScript.</p>
  
  <p>So, I want to show that:</p>
  
  <pre><code>db.find(14);
  </code></pre>
  
  <p>actually consumes time behind the scenes.</p>
  
  <p>How could I illustrate this time dependency and a possible solution that a Promises provides?</p>
  
  <p>What I have so far is this:</p>
  
  <pre><code>  // data store operation take time
    function _findByUsername(username) {
      var user = _.findWhere(Users, {username: username});
      if (!user) {
        Promise.reject(new Error("User not found."));
      }
      return Promise.resolve(user);
    }
  </code></pre>