We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
estimatedDocumentCount
countDocuments
1 parent 5dea3b2 commit 5d956bcCopy full SHA for 5d956bc
lib/service.js
@@ -30,6 +30,7 @@ class Service {
30
this.lean = options.lean === undefined ? true : options.lean;
31
this.overwrite = options.overwrite !== false;
32
this.events = options.events || [];
33
+ this.useEstimatedDocumentCount = !!options.useEstimatedDocumentCount;
34
}
35
36
extend (obj) {
@@ -98,7 +99,7 @@ class Service {
98
99
100
101
if (count) {
- return model.where(query).estimatedDocumentCount().exec().then(executeQuery);
102
+ return model.where(query)[this.useEstimatedDocumentCount ? 'estimatedDocumentCount' : 'countDocuments']().exec().then(executeQuery);
103
104
105
return executeQuery();
0 commit comments