Suppose that I have a series of documents with the following format:
{ \"_id\": \"3_0\", \"values\": [\"1\", \"2\"] }
and I would l
You can use the reduce operator together with the substr operator.
db.collection.aggregate([ { $project: { values: { $reduce: { input: '$values', initialValue: '', in: { $concat: ['$$value', '_', '$$this'] } } } } }, { $project: { values: { $substr: ['$values', 1 , -1]} } }])