This value is saved in the collection
{
name: "jack",
proccess: 1,
point: 60,
cost: 60
},
{
name: "Rose",
proccess: 0,
point: 180,
cost: 360
}
I need change the collection to
{
name: "jack",
proccess: 1,
point: 60,
cost: 120
},
{
name: "Rose",
proccess: 0,
point: 180,
cost: 180
}
I use $addFields
but remove another field data (remove jack)
$data = $db->user_question->aggregate(
[
[
'$match'=>[
'proccess' => 0
]
],
[
'$addFields' =>[
'cost' => '$point'
]
],
[
'$out' => "user_question"
]
]
);
I can't remove $match
have any idea(use update or updateMany)?