PostgresDb.fromUrl constructor

PostgresDb.fromUrl(
  1. String url,
  2. {int port = 5432,
  3. int timeoutInSeconds = 30,
  4. int queryTimeoutInSeconds = 30,
  5. String timeZone = 'UTC',
  6. bool useSSL = false,
  7. bool isUnixSocket = false,
  8. bool allowClearTextPassword = false,
  9. ReplicationMode replicationMode = ReplicationMode.none}
)

Implementation

PostgresDb.fromUrl(
  String url, {
  this.port = 5432,
  int timeoutInSeconds = 30,
  int queryTimeoutInSeconds = 30,
  String timeZone = 'UTC',
  bool useSSL = false,
  bool isUnixSocket = false,
  bool allowClearTextPassword = false,
  ReplicationMode replicationMode = ReplicationMode.none,
}) {
  var base = url.split('postgresql://');
  if (base.length > 1) {
    host = base[1].split('@').last.split('/')[0];
    databaseName = url.split('/').last;
    username = base[1].split(':').first;
    password = base[1].split('@').first.split(':').last;
  } else {
    host = '';
    databaseName = '';
    username = '';
    password = '';
  }

  db = PostgreSQLConnection(
    host,
    port,
    databaseName,
    username: username,
    password: password,
    timeoutInSeconds: timeoutInSeconds,
    queryTimeoutInSeconds: queryTimeoutInSeconds,
    timeZone: timeZone,
    useSSL: useSSL,
    isUnixSocket: isUnixSocket,
    allowClearTextPassword: allowClearTextPassword,
    replicationMode: replicationMode,
  );
}