I solved it using a pipeline inside update command:
db.teamupparticipants.update(
{ },
[{
"$set": {
selectedProfiles: {
$map: {
input: "$appliedProfiles",
as: "profile",
in: "$$profile"
}
},
appliedProfiles: []
},
}],
{ multi: true }
)
Make sure to include the update query inside an array so as to make it a pipeline.