mongodb structure is like;
[
{id: "1" , name: "alex"},
{id: "2" , name: "felix"},
{id: "3" , name: "kelix"},
{id: "4" , name: "hannah"}
]
Let's assume I want to add "s" each document in the document.
[
{id: "1" , name: "alexs"},
{id: "2" , name: "felixs"},
{id: "3" , name: "kelixs"},
{id: "4" , name: "hannahs"}
]
db.list.updateMany({}, { $set: {name: "$name" + "s"})}
But this followed by script contains errors.
Is it possible to update field with its existing value in mongodb?