Skip to content

Commit

Permalink
feat(NODE-4079): estimated document count uses count
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed May 11, 2022
1 parent 15f8870 commit f9d3ce0
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 467 deletions.
3 changes: 1 addition & 2 deletions src/operations/estimated_document_count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export class EstimatedDocumentCountOperation extends CommandOperation<number> {
if (maxWireVersion(server) < 12) {
return this.executeLegacy(server, session, callback);
}
const pipeline = [{ $collStats: { count: {} } }, { $group: { _id: 1, n: { $sum: '$count' } } }];

const cmd: Document = { aggregate: this.collectionName, pipeline, cursor: {} };
const cmd: Document = { count: this.collectionName } };

if (typeof this.options.maxTimeMS === 'number') {
cmd.maxTimeMS = this.options.maxTimeMS;
Expand Down

0 comments on commit f9d3ce0

Please sign in to comment.