Answer the question
In order to leave comments, you need to log in
How to perform concatenation directly in an array?
The collection has a photos field.
When aggregating in $project, you need to reassemble the field to get it like this['photo.jpg', 'photo2.jpg']
['photo.jpg?w=160&h=120', 'photo2.jpg?w=160&h=120']
photo: { $ifNull: [ { $concat: [ { $arrayElemAt: [ '$photos', 0 ] }, '?w=160&h=120' ]}, 'no-photo.jpg'] },
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question