Skip to content

Commit 874f1df

Browse files
committed
fix(NODE-4079): update per comments
1 parent 3969ca7 commit 874f1df

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/collection.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,12 @@ export class Collection<TSchema extends Document = Document> {
10461046
* Gets an estimate of the count of documents in a collection using collection metadata.
10471047
* This will always run a count command on all server versions.
10481048
*
1049+
* due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command,
1050+
* which estimatedDocumentCount uses in its implementation, was not included in v1 of
1051+
* the Stable API, and so users of the Stable API with estimatedDocumentCount are
1052+
* recommended to upgrade their server version to 5.0.9+ or set apiStrict: false to avoid
1053+
* encountering errors.
1054+
*
10491055
* @see {@link https://www.mongodb.com/docs/manual/reference/command/count/#behavior|Count: Behavior}
10501056
* @param options - Optional settings for the command
10511057
* @param callback - An optional callback, a Promise will be returned if none is provided

src/operations/estimated_document_count.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Document } from '../bson';
22
import type { Collection } from '../collection';
3-
import type { MongoServerError } from '../error';
43
import type { Server } from '../sdam/server';
54
import type { ClientSession } from '../sessions';
65
import type { Callback } from '../utils';
@@ -40,7 +39,7 @@ export class EstimatedDocumentCountOperation extends CommandOperation<number> {
4039
}
4140

4241
super.executeCommand(server, session, cmd, (err, response) => {
43-
if (err && (err as MongoServerError).code !== 26) {
42+
if (err) {
4443
callback(err);
4544
return;
4645
}

0 commit comments

Comments
 (0)