Retrieve select info of all users in database.
-
Hello everyone! I have a quick question regarding some database calls.
I currently run a community on NodeBB for gaming. It's Steam-focused, and all registered users must sign in with a Steam account. The system also has a notification-steambot that I wrote that interacts with the users.
At present the bot is hook based, so it requires the user to make certain forum actions. I want to have a list of all steam IDs on hand for pushes, such as mass friend invites to the community, announcements (send messages to all users without hooking the notification system).
Ideally what I'd like to do is run something at a 12-24 hour interval that scrapes all users in the database, and stores all of their SteamIDs in a single array that I can run through.
-
For anyone looking to do this for a plugin, it's easy enough using
getObjectValues()
var db = require.main.require('./src/database') var User = require.main.require('./src/user') db.getObjectValues('steamid:uid', function (err, uids) { if (err) return console.log(err) uids = uids.sort().filter(function(item, pos, ary) { return !pos || item != ary[pos - 1] }) User.getUsersFields(uids, ['username', 'email', 'steamid', 'profileurl'], function (err, users) { if (err) return console.log(err) users.forEach(function (user) { // Do a thing here. console.dir(user) }) }) })