I tried updating with $set operator with positional operator ‘$’. But it is not working as expected. The literal string ‘$total’ is getting set to array element ‘basket_green’.
Hey @NeNaD
Thank you for providing the working example.
That works as desired.
I wonder what if we just need to update single basket?
I tried specifying filters but it doesn’t have any effect.
$map with $cond - to map baskets array based on condition
$eq - to check if name property matches the name of basket that needs to be updated. If it matches update it with the total value of the cart. If it does not match do nothing.
Thanks it is NOW perfect!
Can you please share a link where I can learn more about this?
Basic Aggregation topic in MongoDB Documentation? Or any other more sane resource?