title: Convert ObjectID to String in mongo Aggregation
body: <p>I'm in this scenario right now:
  I have a collection X:</p>
  
  <pre><code>{
    _id:ObjectId('56edbb4d5f084a51131dd4c6'),
    userRef:ObjectId('56edbb4d5f084a51131dd4c6'),
    serialNumber:'A123123',
    ...
  }
  </code></pre>
  
  <p>I need to aggregate all documents, grouping them by the userRef + serialNumber, so I'm trying to use concat like this:</p>
  
  <pre><code>$group: {
          _id: {
              '$concat': ['$userRef','-','$serialNumber']
          },
         ...
  </code></pre>
  
  <p>So basically in my aggregation in MongoDB, I need to group documents by the concatenation of a ObjectId and a string. However, It seems that $concat only accepts strings as parameters:</p>
  
  <pre><code>uncaught exception: aggregate failed: {
  
      "errmsg" : "exception: $concat only supports strings, not OID",
      "code" : 16702,
      "ok" : 0
  }
  </code></pre>
  
  <p>Is there a way to convert an ObjectId to a String within an aggregation expression?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>This <a href="https://stackoverflow.com/questions/36059986/how-to-project-objectid-to-string-value-in-mongodb-aggregate">question</a> is related, but I the solution doesn't fit my problem. (Specially because I can't use ObjectId.toString() during the aggregation)</p>
  
  <p>Indeed I couldn't find any ObjectId().toString() operation in Mongo's documentation, but I wonder if there's any tricky thing that can be done in this case.</p>