title: get mongodb data to nodejs array?
body: <p>I'm having trouble getting mongodb data into nodejs array as follow:<br/></p>
  
  <p>Test db:</p>
  
  <pre><code>{
    "supportTicket" : "viT8B4KsRI7cJF2P2TS7Pd0mfqaI5rtwf",
    "msgId" : 1379304604708.0,
    "username" : "Guest-OSsL2R",
    "message" : "hello",
    "_id" : ObjectId("5236849c3651b78416000001")
  }
  </code></pre>
  
  <p>Nodejs:</p>
  
  <pre><code>function _getMsg(st, callback) {
      db.test.find({ supportTicket: st }).toArray(function (err, docs) {
          callback(docs);
      });
  }
  
  var nodeArr = _getMsg('viT8B4KsRI7cJF2P2TS7Pd0mfqaI5rtwf', function (res) {
      console.log(res); // --&gt; res contain data and printed ok
      return res; 
  });
  
  console.log('return data: ' + nodeArr )  // --&gt; However, nodeArr  is undefined.
  </code></pre>
  
  <p>And here is the result:</p>
  
  <pre><code>return data: undefined
  return data: undefined
  [ { supportTicket: 'viT8B4KsRI7cJF2P2TS7Pd0mfqaI5rtwf',
      msgId: 1379304604708,
      username: 'Guest-OSsL2R',
      message: 'dhfksjdhfkj',
      _id: 5236849c3651b78416000001 } ]
  [ { supportTicket: 'viT8B4KsRI7cJF2P2TS7Pd0mfqaI5rtwf',
      msgId: 1379304604708,
      username: 'Guest-OSsL2R',
      message: 'dhfksjdhfkj',
      _id: 5236849c3651b78416000001 } ]
  </code></pre>
  
  <p>The question is: <strong>How can I get data from test db and assign the data to nodeArr?</strong></p>