diff --git a/rair-node/bin/api/users/users.Service.js b/rair-node/bin/api/users/users.Service.js index 0f0e78f3..b5b566be 100644 --- a/rair-node/bin/api/users/users.Service.js +++ b/rair-node/bin/api/users/users.Service.js @@ -89,12 +89,26 @@ exports.listUsers = async (req, res, next) => { } queriedFields[field] = 1; }); - const list = await User.find({}, queriedFields) - .skip(pageNum * itemsPerPage) - .limit(itemsPerPage); + const [result] = await User.aggregate([ + { + $project: queriedFields, + }, + { + $facet: { + list: [ + { $skip: pageNum * itemsPerPage }, + { $limit: itemsPerPage }, + ], + count: [ + { $count: 'total' }, + ], + }, + }, + ]); return res.json({ success: true, - data: list, + data: result.list, + totalCount: result?.count?.[0]?.total || 0, }); } catch (err) { return next(err); diff --git a/rair-node/bin/index.js b/rair-node/bin/index.js index e531693e..80cc298e 100644 --- a/rair-node/bin/index.js +++ b/rair-node/bin/index.js @@ -55,7 +55,6 @@ async function main() { }, }); - const hls = await StartHLS(); const limiter = rateLimit({