title: Using nodejs : mongodb find then add to Array
body: <p>I made a simple db with a few users in it with mongodb and nodejs. Next im looping through the list and display the users in the list's names etc with sys.puts().</p>
  
  <p>No I am adding the users to an Array() like this:</p>
  
  <pre><code>db.open(function(err, db) {
      db.collection('users', function(err, collection) {
          collection.find({}, {'sort':[['name', 1]]}, function(err, cursor) {
              cursor.each(function(err, user) {
                  if(user != null) {
                      users[user._id] = { 'name':user.name, 'email': user.email };
                      sys.puts("&gt;&gt; Adding user to list... "+ user.name);
  
                  }
              });
              db.close();
          });
      });
  });
  </code></pre>
  
  <p>Is this how I add the users to the array? Because the users.lenght = 0. Im a bit lost now</p>