System allows non-unique email addresses #7

This commit is contained in:
Bryan Ashby 2015-11-27 22:26:00 -07:00
parent d7c35911e8
commit a1f1578048
2 changed files with 98 additions and 3 deletions

View file

@ -15,6 +15,7 @@ exports.User = User;
exports.getUserIdAndName = getUserIdAndName;
exports.getUserName = getUserName;
exports.loadProperties = loadProperties;
exports.getUserIdsWithProperty = getUserIdsWithProperty;
exports.getUserList = getUserList;
function User() {
@ -494,6 +495,26 @@ function loadProperties(options, cb) {
});
}
// :TODO: make this much more flexible - propValue should allow for case-insensitive compare, etc.
function getUserIdsWithProperty(propName, propValue, cb) {
var userIds = [];
userDb.each(
'SELECT user_id ' +
'FROM user_property ' +
'WHERE prop_name = ? AND prop_value = ?;',
[ propName, propValue ],
function rowEntry(err, row) {
if(!err) {
userIds.push(row.user_id);
}
},
function complete() {
cb(null, userIds);
}
);
}
function getUserList(options, cb) {
var userList = [];