admin - download emails.csv, thanks to @akhoury for the gist

This commit is contained in:
psychobunny
2014-01-07 14:01:32 -05:00
parent 4912b8a893
commit cfa4256df5
3 changed files with 33 additions and 0 deletions

View File

@@ -409,6 +409,30 @@ var bcrypt = require('bcrypt'),
});
};
// thanks to @akhoury
User.getUsersCSV = function(callback) {
var csvContent = "";
db.getObjectValues('username:uid', function(err, uids) {
async.each(uids, function(uid, next) {
User.getUserFields(uid, ['email', 'username'], function(err, userData) {
if(err) {
return next(err);
}
csvContent += userData.email+ ',' + userData.username + ',' + uid +'\n';
next();
});
}, function(err) {
if (err) {
throw err;
}
callback(err, csvContent);
});
});
}
User.search = function(username, callback) {
if (!username) {
callback([]);