I need to insert a new field(column) to mongodb collection which has now 5246 documents. The field should be auto incremented . So that i use an for loop . My query is as follows `
for(i=1;i<=5246;i++) {
db.coll.update({},{$set:{"new_field":i}},false,true)
};
But my bad the output is as,
{new_field:5246},{new_field:5246},{new_field:5246},.......
Is there any problem with query..?.