In the group stage I want to create a new array of colors, the colors are objects of two fields (name, value), the resulted array must contain colors with unique color names.
{
$group: {
_id: null,
sizes: { $addToSet: '$combinations.size' },
colors: { $push: '$combinations.color' },
brands: {
$addToSet: { $cond: [{ $eq: ['$brand', ''] }, '$$REMOVE', '$brand'] },
},
topPrice: { $max: `$price.${req.query.reg || 'aud'}` },
bottomPrice: { $min: `$price.${req.query.reg || 'aud'}` },
},
},
the combination.color field is an object is there a way to make a set that will add new colors if they had a unique color name?