Skip to content

Commit c710e0b

Browse files
committed
feat(NODE-4184): do not throw with explain and write conceern
1 parent b9636ee commit c710e0b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/operations/aggregate.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ export class AggregateOperation extends CommandOperation<CursorResponse> {
8585
delete this.options.writeConcern;
8686
}
8787

88-
if (this.explain && this.writeConcern) {
89-
throw new MongoInvalidArgumentError(
90-
'Option "explain" cannot be used on an aggregate call with writeConcern'
91-
);
92-
}
93-
9488
if (options?.cursor != null && typeof options.cursor !== 'object') {
9589
throw new MongoInvalidArgumentError('Cursor options must be an object');
9690
}

test/unit/operations/aggregate.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ describe('AggregateOperation', function () {
77
const db = 'test';
88

99
describe('#constructor', function () {
10+
context('when explain is in the options', function () {
11+
context('when writeConcern is set', function () {
12+
const operation = new AggregateOperation(db, [], {
13+
explain: 'verbose',
14+
writeConcern: { w: 1 }
15+
});
16+
17+
it('sets explain on the operation', function () {
18+
expect(operation.explain.verbosity).to.equal('verbose');
19+
});
20+
21+
it('sets the write concern on the operation', function () {
22+
expect(operation.writeConcern.w).to.equal(1);
23+
});
24+
});
25+
});
26+
1027
context('when out is in the options', function () {
1128
const operation = new AggregateOperation(db, [], { out: 'test', dbName: db });
1229

0 commit comments

Comments
 (0)