Skip to content

Instantly share code, notes, and snippets.

@Lazhari
Created July 23, 2015 08:58
Show Gist options
  • Select an option

  • Save Lazhari/4e05fc1ec5876cd3963d to your computer and use it in GitHub Desktop.

Select an option

Save Lazhari/4e05fc1ec5876cd3963d to your computer and use it in GitHub Desktop.
MongoDB queries : rename operator via $rename

db.users.update({}, {$rename: {'username': 'email', 'password': 'hashedPassword'}, false, true});

example :

Before : [{username: "test@test.com", password: "pwd"}]

after : [{email: "test@test.com", hashedPassword: "pwd"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment