Skip to content

Instantly share code, notes, and snippets.

@barisusakli
Created June 16, 2018 17:01
Show Gist options
  • Save barisusakli/79fdcfabb27066f00aa94175714597d8 to your computer and use it in GitHub Desktop.
Save barisusakli/79fdcfabb27066f00aa94175714597d8 to your computer and use it in GitHub Desktop.
Query user settings and users in mongodb
var uids = [];
db.objects.find({_key: /^user:\d+:settings/, showemail: 1}).forEach(function(obj) {
uids.push(obj._key.split(':')[1]);
});
var userKeys = uids.map(function (uid) {
return 'user:' + uid;
});
print(uids);
db.objects.find({_key: {$in: userKeys}}).forEach(function (userObj) {
print(userObj.username, userObj.email);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment