Mongodb adds a number to each record

  mongodb, question

For example, there is the following set of articles:

{"_id" : ObjectId("98r498jfgragaja9ra4"),"titile":"foo","content":"foo..."}
 {"_id" : ObjectId("498aut89auhgua4940q"),"titile":"bar","content":"bar..."}
 {"_id" : ObjectId("30ua9ah984yhtauiga9"),"titile":"hello","content":"hello..."}

I would like to add one starting from 1 to it.idField, the result is like this:

{"_id" : ObjectId("98r498jfgragaja9ra4"),"titile":"foo","content":"foo...","id":"1"}
 {"_id" : ObjectId("498aut89auhgua4940q"),"titile":"bar","content":"bar...","id":"2"}
 {"_id" : ObjectId("30ua9ah984yhtauiga9"),"titile":"hello","content":"hello...","id":"3"}

What should we do?

You may want to consider why you need this number first. If only fields need to be incremented, the ObjectId used by _id is incremented. And why is there a problem with using a sequence of numbers? I’m hereThis problemThere was an explanation.