lib/mongodb/mongodb/lib/utils.js
function decorateWithCollation(command, target, options) {
  const topology = target.s && target.s.topology;

  if (!topology) {
    throw new TypeError('parameter "target" is missing a topology');
  }

  const capabilities = target.s.topology.capabilities();
  if (options.collation && typeof options.collation === 'object') {
    if (capabilities && capabilities.commandsTakeCollation) {
      command.collation = options.collation;
    } else {
      throw new MongoError(`server ${topology.s.coreTopology.name} does not support collation`);
    }
  }
}
function decorateWithCollation(command, target, options) {
  const topology = target.s && target.s.topology;

  if (!topology) {
    throw new TypeError('parameter "target" is missing a topology');
  }

  const capabilities = target.s.topology.capabilities();
  if (options.collation && typeof options.collation === 'object') {
    if (capabilities && capabilities.commandsTakeCollation) {
      command.collation = options.collation;
    } else {
      throw new MongoError(`server ${topology.s.coreTopology.name} does not support collation`);
    }
  }
}
function decorateWithCollation ( command , target , options ) { const topology = target . s && target . s . topology ; if ( ! topology ) { throw new TypeError ( 'parameter "target" is missing a topology' ) ; } const capabilities = target . s . topology . capabilities ( ) ; if ( options . collation && typeof options . collation === 'object' ) { if ( capabilities && capabilities . commandsTakeCollation ) { command . collation = options . collation ; } else { throw new MongoError ( ` ${ topology . s . coreTopology . name } ` ) ; } } }
Applies collation to a given command.

@param {object} [command] the command on which to apply collation
@param {(Cursor|Collection)} [target] target of command
@param {object} [options] options containing collation settings
Applies collation to a given command .