Skip to content

Commit c43e303

Browse files
committed
fix: countQuery should return a query rather than the pipeline stages
1 parent 05bebfd commit c43e303

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/mongoose-aggregate-paginate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ function aggregatePaginate(query, options, callback) {
142142
} else {
143143
const [pipeline, countPipeline] = constructPipelines();
144144

145-
const countQuery = options.countQuery ? options.countQuery : countPipeline;
145+
const countQuery = options.countQuery
146+
? options.countQuery
147+
: this.aggregate(countPipeline);
146148

147149
if (allowDiskUse) {
148150
countQuery.allowDiskUse(true);

0 commit comments

Comments
 (0)