connect method

Future<void> connect(
  1. DBConfig config,
  2. String connectionName
)

Implementation

Future<void> connect(DBConfig config, String connectionName) async {
  try {
    final connection = DatabaseConnectionFactory.createConnection(config);
    await connection.connect();

    final monitoredConnection = DatabaseConnectionProxy(
      connection,
      connectionName,
      _monitor,
    );
    connectionMap[connectionName] = monitoredConnection;

    if (!config.pool) {
      await _checkDatabaseHealth(monitoredConnection);
    }
  } on InvalidArgumentException catch (e) {
    Logger.log(e.message, type: Logger.ERROR);
    throw DatabaseException("Failed to connect to the database", e);
  }
}