Skip to content

Commit

Permalink
[FIX] Admin Users list pagination (#21469)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored and sampaiodiego committed Apr 8, 2021
1 parent 1dc4ee8 commit 50d4a5a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,29 +254,29 @@ API.v1.addRoute('users.list', { authRequired: true }, {
},
},
},
{
$skip: offset,
},
{
$limit: count,
},
{
$facet: {
sortedResults: [{ $sort: actualSort }],
totalCount: [{ $count: 'value' }],
sortedResults: [{
$sort: actualSort,
}, {
$skip: offset,
}, {
$limit: count,
}],
totalCount: [{ $group: { _id: null, total: { $sum: 1 } } }],
},
},
])
.toArray(),
);

const { sortedResults: users, totalCount } = result[0];
const { sortedResults: users, totalCount: [{ total }] } = result[0];

return API.v1.success({
users,
count: users.length,
offset,
total: totalCount[0].value,
total,
});
},
});
Expand Down

0 comments on commit 50d4a5a

Please sign in to comment.