open static method

Future<HiveCrdt> open(
  1. Iterable<String> tables, {
  2. String? path,
  3. String? prefix,
})

Create or open tables and store them in path. Table names are used as file names. Use prefix to prepend the filename, otherwise Hive will prevent opening multiple boxes with the same tables. Useful for testing.

Implementation

static Future<HiveCrdt> open(Iterable<String> tables,
    {String? path, String? prefix}) async {
  assert(tables.isNotEmpty);
  assert(tables.length == tables.toSet().length);

  final boxes = {
    for (final table in tables)
      table: await Hive.openBox<Record>('${prefix ?? ''}_$table', path: path)
  };

  final crdt = HiveCrdt._(tables, boxes);
  return crdt;
}