Skip to content

Commit caaa9aa

Browse files
mbroadstdaprahamian
authored andcommitted
refactor: support query in EstimatedDocumentCountOperation
1 parent 884d46f commit caaa9aa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/operations/estimated_document_count.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@ const defineAspects = require('./operation').defineAspects;
55
const CommandOperationV2 = require('./command_v2');
66

77
class EstimatedDocumentCountOperation extends CommandOperationV2 {
8-
constructor(collection, options) {
8+
constructor(collection, query, options) {
9+
if (typeof options === 'undefined') {
10+
options = query;
11+
query = undefined;
12+
}
13+
914
super(collection, options);
1015
this.collectionName = collection.s.namespace.collection;
16+
if (query) {
17+
this.query = query;
18+
}
1119
}
1220

1321
execute(server, callback) {
1422
const options = this.options;
1523
const cmd = { count: this.collectionName };
24+
25+
if (this.query) {
26+
cmd.query = this.query;
27+
}
28+
1629
if (typeof options.skip === 'number') {
1730
cmd.skip = options.skip;
1831
}

0 commit comments

Comments
 (0)