processOptions method

void processOptions(
  1. Map<String, dynamic> command
)
inherited

Implementation

void processOptions(Map<String, dynamic> command) {
  // Get the db name we are executing against
  final dbName = (options[keyDbName] as String?) ??
      ((options[keyAuthdb] as String?) ?? db.databaseName);
  if (dbName == null) {
    throw MongoDartError('Database name not specified');
  }
  options.removeWhere((key, value) => key == keyDbName || key == keyAuthdb);
  //if (dbName != null) {
  command[keyDatabaseName] = dbName;
  //}
  if (hasAspect(Aspect.writeOperation)) {
    applyWriteConcern(options,
        options: options, db: db, collection: collection);
    readPreference = ReadPreference.primary;
  } else {
    // Todo we have to manage Session
    options.remove(keyWriteConcern);
    // if Aspect is noInheritOptions, here a separated method is maintained
    // even if not necessary, waiting for the future check of the session
    // value.
    if (collection != null) {
      readPreference = resolveReadPreference(collection, options,
          inheritReadPreference: !hasAspect(Aspect.noInheritOptions));
    } else {
      readPreference = resolveReadPreference(db, options,
          inheritReadPreference: !hasAspect(Aspect.noInheritOptions));
    }
  }
  options.remove(keyReadPreference);

  options.removeWhere((key, value) => command.containsKey(key));
}