I have an existing MongoDB collection containing user names. The user names contain both lower case and upper case letters.
I want to update all the user names so they only contain lower case letters.
I have tried this script, but it didn't work
db.myCollection.find().forEach(
function(e) {
e.UserName = $toLower(e.UserName);
db.myCollection.save(e);
}
)
See Question&Answers more detail:os