title: How do i access the value within callback function in Mongoose/nodejs?
body: <p>I wrote a function that reads an item from mongoDB using Mongoose, and i want the result to be returned to the caller:</p>
  
  <pre><code>ecommerceSchema.methods.GetItemBySku = function (req, res) {
      var InventoryItemModel = EntityCache.InventoryItem;
  
      var myItem;
      InventoryItemModel.findOne({'Sku' : req.query.sku}, function (err, item) {
          // the result is in item
          myItem = item;
          //return item doesn't work here!!!!
      });
  
      //the value of "myItem" is undefined because nodejs's non-blocking feature
      return myItem;
  };
  </code></pre>
  
  <p>However as you can see, the result is only valid in the callback function of "findOne". I only need the value of "item" to be returned to the caller function, instead doing anything processing in the callback function. Is there any way to do this?</p>
  
  <p>Thank you very much!</p>