Skip to content

Commit

Permalink
refactor(applyWriteConcern): remove check for capabilities
Browse files Browse the repository at this point in the history
writeConcern has been supported since 2.6, we only need to check
for server support in aggregation's $out in which case support was
deferred to 3.4
  • Loading branch information
mbroadst committed Apr 16, 2018
1 parent 7d626c0 commit 14d7f93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,11 @@ Collection.prototype.aggregate = function(pipeline, options, callback) {
}

// Decorate command with writeConcern if out has been specified
if (pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) {
if (
pipeline.length > 0 &&
pipeline[pipeline.length - 1]['$out'] &&
self.s.topology.capabilities().commandsTakeWriteConcern
) {
applyWriteConcern(command, { db: self.s.db, collection: self }, options);
}

Expand Down
5 changes: 0 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,6 @@ function applyWriteConcern(target, sources, options) {
options = options || {};
const db = sources.db;
const coll = sources.collection;
const topology = db ? db.s.topology : coll.s.topology;

if (!topology.capabilities().commandsTakeWriteConcern) {
return target;
}

// NOTE: there is probably a much better place for this
if (db && db.s.options.retryWrites) {
Expand Down

0 comments on commit 14d7f93

Please sign in to comment.