I have a collection of people:
{
name: Juan,
age: 21
}
and now , I want to achieve the following:
{
name: Juan,
age: 21,
name_reply:Juan
}
I have tried using:
db.people.updateMany(
{"name_reply":null},
[{$set:{name_reply:"$name"}}]
);
but the following appears. Expected type object but found array.
How could I update a mongo field using the value of another field?