Skip to content

Commit

Permalink
fix(keynumbers): If limit is 0, no limit
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Dec 1, 2022
1 parent 0ea03ed commit 3c0f4bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/structures/keynumbers/keynumbers.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function find(req, res, next) {
{ $skip: skip },
];
if (sort) { queryPipeline.push({ $sort: parseSortParams(sort) }); }
queryPipeline.push({ $limit: limit });
if (limit && limit > 0) { queryPipeline.push({ $limit: limit }); }
const data = await db.collection('keynumbers').aggregate([
{ $facet: { data: queryPipeline, total: countPipeline } },
{ $project: { data: 1, total: { $arrayElemAt: ['$total', 0] } } },
Expand Down

0 comments on commit 3c0f4bd

Please sign in to comment.