title: return bool value from middleware to express controller
body: <p>I want to return a boolean value from middleware defined as
  </p>
  
  <pre><code>module.exports = {
     authenticatepracticename: function(pname) {  
         ecollection.find({ $and: [{'name':pname},{'status' : 'active'}] }).exec(function (err, result) {
             if (err) return false;
             if(result.length == 1){
                 // console.log('true');
                 return true;
              }
              else{
                  // console.log('false');
                  return false;
              }
         });  
     },
     // ... 
  }
  </code></pre>
  
  <p>to my express controller defined as 
  </p>
  
  <pre><code>exports.checkcredentails = function (req, res) {  
      var result = practice.authenticatepracticename(practiceName);
  }
  </code></pre>
  
  <p>but result is coming <code>undefined</code> even though middleware function is getting called.</p>