title: MongoDB aggregate: $lookup by _id, then get first element value
body: <p>When I do <code>$lookup</code>, in my case the <code>foreignField:"_id"</code>, I get the found element in an array. Here is one document from the output after <code>$lookup</code> has been done to retrieve <code>fromUser</code> and <code>toUser</code> from the <code>users</code> collection:</p>
  
  <pre><code>{ 
      _id : { from : 57b8da368e4a6e1f0043cb3d, to : 57c381af7008e51f009d92df }, 
      fromUser : [
          {
              _id : 57b8da368e4a6e1f0043cb3d, 
              userName: "A"
          }
      ], 
      toUser : [
          {
              _id : 57c381af7008e51f009d92df, 
              userName: "B"
          }
      ]
  }
  </code></pre>
  
  <p>As you can notice <code>fromUser</code> and <code>toUser</code> are arrays. How to project <code>fromUser</code> and <code>toUser</code> so instead of arrays they contain just the user's <code>userName</code>, like here:</p>
  
  <pre><code>{
      _id : { from : 57b8da368e4a6e1f0043cb3d, to : 57c381af7008e51f009d92df },
      fromUser: "A",
      toUser: "B"
  }
  </code></pre>