open static method
Future<DataLocalDatabase>
open({
- required String name,
- required DataLocalStorage storage,
- DataLocalEncryptionProvider encryption = const DataLocalNoEncryptionProvider(),
- DataLocalClock clock = const DataLocalSystemClock(),
- DataLocalDocumentIdGenerator? idGenerator,
- DataLocalFailureInjector? failureInjector,
Opens a database and performs pending journal recovery.
encryption defaults to plaintext storage and must be configured
explicitly when data-at-rest encryption is required.
Implementation
static Future<DataLocalDatabase> open({
required String name,
required DataLocalStorage storage,
DataLocalEncryptionProvider encryption =
const DataLocalNoEncryptionProvider(),
DataLocalClock clock = const DataLocalSystemClock(),
DataLocalDocumentIdGenerator? idGenerator,
DataLocalFailureInjector? failureInjector,
}) async {
final context = DataLocalStorageContext(databaseName: name);
await storage.open(context);
final coordinator = DataLocalCommitCoordinator(
storage: storage,
failureInjector: failureInjector,
);
await coordinator.recover();
if (storage
case final DataLocalIntegrityVerifyingStorage verifyingStorage) {
await verifyingStorage.verifyIntegrity();
}
return DataLocalDatabase._(
name: context.databaseName,
storage: storage,
encryption: encryption,
clock: clock,
idGenerator: idGenerator ?? DataLocalSecureDocumentIdGenerator(),
coordinator: coordinator,
);
}