create static method

Future<DartApiDB> create(
  1. DbConfig config
)

Dynamically instantiates the correct driver

Implementation

static Future<DartApiDB> create(DbConfig config) async {
  late final DartApiDB db;

  switch (config.type) {
    case DbType.postgres:
      db = PostgresDatabase(config);
      break;

    case DbType.mysql:
      throw UnimplementedError('MySQL support is not implemented yet.');
  }

  await db.connect();
  return db;
}