Concat String by Group
问题 In my query I want to combine same item into a String group by _id here is my document "_id" : ObjectId("59e955e633d64c81875bfd2f"), "tag_id" : 1, "client_id" : "10001" "_id" : ObjectId("59e955e633d64c81875bfd30"), "tag_id" : 1, "client_id" : "10002" I hope the output would be "_id" : 1 "client_id" : "10001,10002" 回答1: You can do it with the aggregation framework as a "two step" operation. Which is to first accumulate the items to an array via $push withing a $group pipeline, and then to use