Skip to content

Commit 5d956bc

Browse files
giovannilobitosdaffl
authored andcommitted
estimatedDocumentCount to countDocuments (#252)
* Set default for counting of total documents to . Added option for using of instead. * Fixed typo
1 parent 5dea3b2 commit 5d956bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Service {
3030
this.lean = options.lean === undefined ? true : options.lean;
3131
this.overwrite = options.overwrite !== false;
3232
this.events = options.events || [];
33+
this.useEstimatedDocumentCount = !!options.useEstimatedDocumentCount;
3334
}
3435

3536
extend (obj) {
@@ -98,7 +99,7 @@ class Service {
9899
}
99100

100101
if (count) {
101-
return model.where(query).estimatedDocumentCount().exec().then(executeQuery);
102+
return model.where(query)[this.useEstimatedDocumentCount ? 'estimatedDocumentCount' : 'countDocuments']().exec().then(executeQuery);
102103
}
103104

104105
return executeQuery();

0 commit comments

Comments
 (0)