title: How to use MongoDBs aggregate `$lookup` as `findOne()`
body: <p>So as you all know, <code>find()</code> returns an array of results, with <code>findOne()</code> returning just a simply object.</p>
  
  <p>With Angular, this makes a huge difference. Instead of going <code>{{myresult[0].name}}</code>, I can simply just write <code>{{myresult.name}}</code>.</p>
  
  <p>I have found that the <code>$lookup</code> method in the aggregate pipeline returns an array of results instead of just a single object.</p>
  
  <p>For example, I have two colletions:</p>
  
  <p><strong><code>users</code> collection:</strong></p>
  
  <pre><code>[{
    "firstName": "John",
    "lastName": "Smith",
    "country": 123
  }, {
    "firstName": "Luke",
    "lastName": "Jones",
    "country": 321
  }]
  </code></pre>
  
  <p><strong><code>countries</code> collection:</strong></p>
  
  <pre><code>[{
    "name": "Australia",
    "code": "AU",
    "_id": 123
  }, {
    "name": "New Zealand",
    "code": "NZ",
    "_id": 321
  }]
  </code></pre>
  
  <p><strong>My aggregate <code>$lookup</code>:</strong></p>
  
  <pre><code>db.users.aggregate([{
    $project: {
      "fullName": {
        $concat: ["$firstName", " ", "$lastName"]
      },
      "country": "$country"
    }
  }, {
    $lookup: {
      from: "countries",
      localField: "country",
      foreignField: "_id",
      as: "country"
    }
  }])
  </code></pre>
  
  <p><strong>The results from the query:</strong></p>
  
  <pre><code>[{
    "fullName": "John Smith",
    "country": [{
      "name": "Australia",
      "code": "AU",
      "_id": 123
    }]
  }, {
   "fullName": "Luke Jones",
   "country": [{
     "name": "New Zealand",
     "code": "NZ",
     "_id": 321
   }]
  }]
  </code></pre>
  
  <p>As you can see by the above results, each <code>country</code> is an array instead of a single object like <code>"country": {....}</code>.</p>
  
  <p>How can I have my <code>$lookup</code> return a single object instead of an array since it will only ever match a single document?</p>