0
我想將一個id
字段添加到集合中,編號從1
開始。 例如, 有一個收集的文章: MongoDB:如何將一個`id`字段添加到集合中?
{"_id" : ObjectId("98r498jfgragaja9ra4"),"titile":"foo","content":"foo..."}
{"_id" : ObjectId("498aut89auhgua4940q"),"titile":"bar","content":"bar..."}
{"_id" : ObjectId("30ua9ah984yhtauiga9"),"titile":"hello","content":"hello..."}
加入id
後場
{"_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"}
怎麼辦呢?
您需要向我們展示了到目前爲止你已經嘗試什麼,即使它不工作... – Roberto