Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mongo Update Queries

Add new field to mongo document and set incremental values

var cursor = db.getCollection("FacetTest").find();

var i = 1;
    db.getCollection("FacetTest").update({_id: x._id}, {$set:{Order: NumberInt(i)}}, {
     upsert: false,
     multi: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment