Skip to content

feat(NODE-4184): do not throw with explain and write conceern #4582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/operations/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ export class AggregateOperation extends CommandOperation<CursorResponse> {
delete this.options.writeConcern;
}

if (this.explain && this.writeConcern) {
throw new MongoInvalidArgumentError(
'Option "explain" cannot be used on an aggregate call with writeConcern'
);
}

if (options?.cursor != null && typeof options.cursor !== 'object') {
throw new MongoInvalidArgumentError('Cursor options must be an object');
}
Expand Down
17 changes: 17 additions & 0 deletions test/unit/operations/aggregate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ describe('AggregateOperation', function () {
const db = 'test';

describe('#constructor', function () {
context('when explain is in the options', function () {
context('when writeConcern is set', function () {
const operation = new AggregateOperation(db, [], {
explain: 'verbose',
writeConcern: { w: 1 }
});

it('sets explain on the operation', function () {
expect(operation.explain.verbosity).to.equal('verbose');
});

it('sets the write concern on the operation', function () {
expect(operation.writeConcern.w).to.equal(1);
});
});
});

context('when out is in the options', function () {
const operation = new AggregateOperation(db, [], { out: 'test', dbName: db });

Expand Down