code: function applyWriteConcern(target, sources, options) {
    options = options || {};
    const db = sources.db;
    const coll = sources.collection;
  
    if (options.session && options.session.inTransaction()) {
      // writeConcern is not allowed within a multi-statement transaction
      if (target.writeConcern) {
        delete target.writeConcern;
      }
  
      return target;
    }
  
    if (options.w != null || options.j != null || options.fsync != null) {
      const writeConcern = {};
      if (options.w != null) writeConcern.w = options.w;
      if (options.wtimeout != null) writeConcern.wtimeout = options.wtimeout;
      if (options.j != null) writeConcern.j = options.j;
      if (options.fsync != null) writeConcern.fsync = options.fsync;
      return Object.assign(target, { writeConcern });
    }
  
    if (
      coll &&
      (coll.writeConcern.w != null || coll.writeConcern.j != null || coll.writeConcern.fsync != null)
    ) {
      return Object.assign(target, { writeConcern: Object.assign({}, coll.writeConcern) });
    }
  
    if (
      db &&
      (db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null)
    ) {
      return Object.assign(target, { writeConcern: Object.assign({}, db.writeConcern) });
    }
  
    return target;
  }
docs: Applies a write concern to a command based on well defined inheritance rules, optionally
  detecting support for the write concern in the first place.
  
  @param {Object} target the target command we will be applying the write concern to
  @param {Object} sources sources where we can inherit default write concerns from
  @param {Object} [options] optional settings passed into a command for write concern overrides
  @returns {Object} the (now) decorated target