I\'m in this scenario right now: I have a collection X:
{ _id:ObjectId(\'56edbb4d5f084a51131dd4c6\'), userRef:ObjectId(\'56edbb4d5f084a51131dd4c6\'), seria
Now you can try with $toString aggregation which simply converts ObjectId to string
db.collection.aggregate([ { "$addFields": { "userRef": { "$toString": "$userRef" } }}, { "$group": { "_id": { "$concat": ["$userRef", "-", "$serialNumber"] } }} ])
You can check the output here