How to change aggragte value in node js - mongodb
i have $project
:
$project : {
type: '$data.type',
}
and it give me output :
'type' : [
'bold',
'bold',
'regular',
'bold',
'regular'
]
the i want to change the output
if bold, then thick, else thin
i have try to use $cond
and $switch
, but idk why the i get just 1 output and that's default output
type: {
$switch : {
branches : [
{
case : { $eq : ['$data.type', 'bold']}, then: 'thick'
},
{
case : { $eq : ['$data.type', 'regular']}, then: 'thin'
},
],
default: ""
}
},
output :
"type": "",
can u all help me to solve this ? i have trying the $cond
$eq
too, but the output still default output
thank you for helping guys
Aucun commentaire:
Enregistrer un commentaire