title: How do you do a "join" on an array in mongoose (mongodb) with node.js?
body: <p>How do you do a "join" (i know it is not the correct term) with an array of messages in mongoose?</p>
  
  <p>I tried looping over all the messages and querying to get the user info but it is not working:</p>
  
  <pre><code>messages.forEach(function (message, index) {
    User.findById(message.userId, function (err, user) {
      messages[index].user = user
    })
  })
  
  console.log(messages) // the user info is not attatched
  </code></pre>
  
  <p>So how is this accomplished with mongoose and node.js?</p>