code: function(options) {
    var r = null;
    if (options.readPreference) {
      r = options.readPreference;
    } else {
      return options;
    }
  
    if (typeof r === 'string') {
      options.readPreference = new ReadPreference(r);
    } else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
      const mode = r.mode || r.preference;
      if (mode && typeof mode === 'string') {
        options.readPreference = new ReadPreference(mode, r.tags, {
          maxStalenessSeconds: r.maxStalenessSeconds
        });
      }
    } else if (!(r instanceof ReadPreference)) {
      throw new TypeError('Invalid read preference: ' + r);
    }
  
    return options;
  }
docs: Figure out the read preference