Skip to content

Commit

Permalink
fix(NODE-4079): update per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed May 17, 2022
1 parent 3969ca7 commit 874f1df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,12 @@ export class Collection<TSchema extends Document = Document> {
* Gets an estimate of the count of documents in a collection using collection metadata.
* This will always run a count command on all server versions.
*
* due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command,
* which estimatedDocumentCount uses in its implementation, was not included in v1 of
* the Stable API, and so users of the Stable API with estimatedDocumentCount are
* recommended to upgrade their server version to 5.0.9+ or set apiStrict: false to avoid
* encountering errors.
*
* @see {@link https://www.mongodb.com/docs/manual/reference/command/count/#behavior|Count: Behavior}
* @param options - Optional settings for the command
* @param callback - An optional callback, a Promise will be returned if none is provided
Expand Down
3 changes: 1 addition & 2 deletions src/operations/estimated_document_count.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Document } from '../bson';
import type { Collection } from '../collection';
import type { MongoServerError } from '../error';
import type { Server } from '../sdam/server';
import type { ClientSession } from '../sessions';
import type { Callback } from '../utils';
Expand Down Expand Up @@ -40,7 +39,7 @@ export class EstimatedDocumentCountOperation extends CommandOperation<number> {
}

super.executeCommand(server, session, cmd, (err, response) => {
if (err && (err as MongoServerError).code !== 26) {
if (err) {
callback(err);
return;
}
Expand Down

0 comments on commit 874f1df

Please sign in to comment.