title: mongodb aggregate with match, lookup and project
body: <p>I'm new to node js with mongodb programming. I'm using <code>mongodb</code> module and I want to perform a post "join" with user public info. The code I'm using right now is as follows:</p>
  
  <pre><code>db.collection('post').aggregate({ 
    '$match': { category: 'video', status: 'online' },
    '$lookup': 
     { 
       from: 'user',
       localField: 'user',
       foreignField: '_id',
       as:'user'
    },
    '$project': 
       { text: 1,
         imgs: 1,
         video: 1,
         datetime: 1,
         user: 1,
         category: 1,
         marketplace: 1,
         tags: 1 } }
  })
  .toArray(function(err,posts){console.log(posts)})
  </code></pre>
  
  <p>but nothing works. I only get posts even if category is not <code>music</code> and the lookup does not bind the object to the result array. </p>
  
  <p><strong>UPDATE</strong>
  the aggregate doesn't work even if letting the $match parameter only as the aggregate query</p>
  
  <p>the collections returned are</p>
  
  <pre><code>[
    {
      "_id":"5aed6cbbd8362bcc0f2d95ab",
      "category":"music",
      "video":"",
      "imgs":[],
      "videoImage":false,
      "text":"post text",
      "tags":{["first","try"]}, 
      "datetime":1525509307968,
      "user":"FuRRTBEYBmCSDPJkN",
      "status":"online","marketplace":null}, 
    { 
      "_id":"5aedc26c6defa3d3a6de7126", "category":"music",
      "video":"https://www.youtube.com/embed/1yvLYJ2Fe_c", 
      "imgs" [],
      "videoImage":"https://i.ytimg.com/vi/1yvLYJ2Fe_c/hqdefault.jpg",
      "text":"second post text second post text second post text ",
      "tags":{["second","post"]},
      "datetime":1525531244425,
      "user":"FuRRTBEYBmCSDPJkN",
      "status":"online",
      "marketplace":null
     }
  ]
  </code></pre>
  
  <p>the expected results would be</p>
  
  <pre><code>[
    {
      "_id":"3aed6cbbd8362bcc0f2d95ab",
      "category":"video",
      "video":"",
      "imgs":[],
      "videoImage":false,
      "text":"post text",
      "tags":{["first","video"]}, 
      "datetime":1525509307968,
      "user": {_id: 'FuRRTBEYBmCSDPJkN', username: 'user1',img: '/path/to/the/image.png'},
      "status":"online","marketplace":null}, 
    { 
      "_id":"4aedc26c6defa3d3a6de7126", "category":"video",
      "video":"https://www.youtube.com/embed/1yvLYJ2Fe_c", 
      "imgs" [],
      "videoImage":"https://i.ytimg.com/vi/1yvLYJ2Fe_c/hqdefault.jpg",
      "text":"second video ",
      "tags":{["second","video"]},
      "datetime":1525531244425,
      "user":{_id: 'FuRRTBEYBmCSDPJkN', username: 'user1',img: '/path/to/the/image.png'},
      "status":"online",
      "marketplace":null
     }
  ]
  </code></pre>
  
  <hr>