title: validating against mongodb with nodejs
body: <p>It should be very awesome to use non-blocking code but I'm running out of ideas how to acomplish this task. I have to validate a value by making few db queries like so:</p>
  
  <pre><code>validate = function() {
    var valid = true;
    db.collection('posts').findOne({date: ....}, function(err, post){ 
      if (..) valid = false
    }
    db.collection('posts').findOne({author: .....}, function(err, post){
      if (..) valid = false
    }
    return valid;
  }
  </code></pre>
  
  <p>It is very good that validations can run in concurent manner, but the problem is how to return the final state. Obviously my example will not work. The function will return before db queries execution.</p>