Add mailboxdb.getByOwnerId
This commit is contained in:
@@ -8,6 +8,7 @@ exports = module.exports = {
|
||||
getAll: getAll,
|
||||
getAliases: getAliases,
|
||||
setAliases: setAliases,
|
||||
getByOwnerId: getByOwnerId,
|
||||
delByOwnerId: delByOwnerId,
|
||||
|
||||
_clear: clear,
|
||||
@@ -111,6 +112,18 @@ function get(name, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getByOwnerId(ownerId, callback) {
|
||||
assert.strictEqual(typeof ownerId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
database.query('SELECT ' + MAILBOX_FIELDS + ' FROM mailboxes WHERE ownerId = ? ', [ ownerId ], function (error, results) {
|
||||
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
|
||||
if (results.length === 0) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
|
||||
|
||||
callback(null, results[0]);
|
||||
});
|
||||
}
|
||||
|
||||
function getAll(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user