You can use `$split` to split with `+` sign and then `$arrayElemAt` to get the last index.
db.collection.aggregate([
{
$project: {
value: {
$arrayElemAt: [
{
$split: [
"$value",
"+"
]
},
-1
]
}
}
}
])
You should iterate through. For your specific case:
db.person.find().snapshot().forEach(
function (elem) {
db.person.update(
{
_id: elem._id
},
{
$set: {
name: elem.firstname + ' ' + elem.lastname
}
}
);
}
);