Add user pagination to rest api

This commit is contained in:
Johannes Zellner
2019-01-14 16:39:20 +01:00
parent 1a3d5d0bdc
commit 3470252768
3 changed files with 23 additions and 4 deletions

View File

@@ -6,7 +6,8 @@ exports = module.exports = {
removePrivateFields: removePrivateFields,
removeRestrictedFields: removeRestrictedFields,
list: list,
getAll: getAll,
getAllPaged: getAllPaged,
create: create,
isActivated: isActivated,
verify: verify,
@@ -304,7 +305,7 @@ function removeUser(userId, auditSource, callback) {
});
}
function list(callback) {
function getAll(callback) {
assert.strictEqual(typeof callback, 'function');
userdb.getAllWithGroupIds(function (error, results) {
@@ -314,6 +315,18 @@ function list(callback) {
});
}
function getAllPaged(page, perPage, callback) {
assert.strictEqual(typeof page, 'number');
assert.strictEqual(typeof perPage, 'number');
assert.strictEqual(typeof callback, 'function');
userdb.getAllWithGroupIdsPaged(page, perPage, function (error, results) {
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
return callback(null, results);
});
}
function count(callback) {
assert.strictEqual(typeof callback, 'function');