Skip to content

Instantly share code, notes, and snippets.

@NicolasGeraud
Last active October 11, 2018 08:33
Show Gist options
  • Save NicolasGeraud/b8ef6e081ce954d4bd7f1454d4856724 to your computer and use it in GitHub Desktop.
Save NicolasGeraud/b8ef6e081ce954d4bd7f1454d4856724 to your computer and use it in GitHub Desktop.
anonymize user emails
db.users.find().forEach(
function(user) {
if (user.email) {
var newEmail = user.email + '.anon'
print(user.email + " => " + newEmail);
db.users.updateOne(
{ _id: user._id },
{ $set:{ 'email': newEmail } },
{ upsert: false });
}
});
db.genericnotificationconfigs.find({'notifier': 'default-email'}).forEach(
function(notif) {
var newEmail = notif.config + '.anon'
print(notif.config + " => " + newEmail);
db.genericnotificationconfigs.updateOne(
{ _id: notif._id },
{ $set:{ 'config': newEmail } },
{ upsert: false });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment