title: MongoDB aggregate project return an array of _id
body: <p>As we know if we want to get an array of _id we can do:</p>
  
  <pre><code>db.collections.distinct("_id");
  </code></pre>
  
  <p>My question is how can I get an array of _id if I need to do a complicate logic with aggregate.
  Ex:</p>
  
  <pre><code>db.getCollection('users').aggregate({
          $match : {
              is_register_completed : { $ne : true}
          }
      }
      //other operator like $lookup, $group
      ,
       {
           $project : {_id:1}
      }
       )
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>{
  "_id" : "1",
  "_id" : "2"
  }
  </code></pre>
  
  <p>what i want is just like we do distinct</p>
  
  <pre><code>{[1,2]}
  </code></pre>
  
  <p><strong>Updated:</strong>
  this is what i try to do with $group</p>
  
  <pre><code>db.getCollection('users').aggregate({
          $match : {
              is_register_completed : { $ne : true}
          }
      },
      {
          $group: {
          _id:null, all:{$addToSet: "$_id"}
          }
       }, {$project: {_id:0,all:1}}
       )
  </code></pre>
  
  <p>but i still get</p>
  
  <pre><code>{
  all : ["1","2"]
  }
  </code></pre>
  
  <p>or I can do <code>.map(function(el) { return el._id })</code> after getting </p>
  
  <pre><code>{
      "_id" : "1",
      "_id" : "2"
      }
  </code></pre>
  
  <p>, but the map is client side transformation which I think it will affect the performance.</p>