I have an existing collection users where the _id field is a string instead of an ObjectId.
Is there a query that can update all documents in the collection and add a unique ObjectId for each document to using a new field called UID?
You can generate a new ObjectId using new ObjectId() in the shell.
db.users.find().forEach(function(doc){
doc.UID = new ObjectId();
db.users.save(doc);
})