I use MongoDB 6.0.
And I'm just trying to update each field with sequence number in mongosh. I want the field modified and update the collection.
The sequence_number
will be given from random number.
Here's the example:
{
_id: "1",
name: "Ken"
},
{
_id: "2",
name: "Ryu"
}
And what I want to do is this:
{
_id: "1",
name: "Ken",
sequence_number: "10"
},
{
_id: "2",
name: "Ryu",
sequence_number: "11"
}
Does anyone help me?
Thanks.
I read the question.
How can I add a new field from another one value?
But the approach is a little different.