title: Why can't I access a mongodb query result outside of a function?
body: <p>Why can't I access my result?</p>
  
  <pre><code>var myList = [];
  db.collection('clientes').find({}, {projection: {_id:0, pedido: 1}}).toArray((err, result) =&gt; {
     if (err) return console.log(err);
     myList.push(result);
  })
  console.log(myList);`
  </code></pre>
  
  <p>My console log is giving me 'undefined', why?</p>