OpenDatabase typedef
Opens (creating it if needed) the SQLite database called path for the
offline cache. Pass one to FirebaseFirestore.instanceFor(openDatabase: ...); this
package does not depend on a SQLite binding itself. Without it the cache is
kept in memory only.
path is a database name chosen by Firestore (unique per app and
database), not a full file path: the opener decides where the file lives.
The opener must, in this order: call onConfigure; if the file is new, call
onCreate with version and store version as the schema version
(PRAGMA user_version); otherwise call onUpgrade or onDowngrade when the
stored version is lower or higher than version and then store version;
finally call onOpen. The callbacks run Firestore's own schema migrations,
so they must be awaited before the returned future completes.
The callbacks may be called inside a transaction of the opener. Outside of
one, Firestore runs the migration in a transaction of its own
(BEGIN EXCLUSIVE), reads PRAGMA user_version in it and migrates from the
version it finds there: another client may have migrated the same file
since the opener looked.
package:cloud_firestore_dart_sqlite has a complete implementation on top
of package:sqlite3 for the VM, Flutter and the web (sqliteOpener).
Implementation
typedef OpenDatabase =
Future<Database> Function(
String path, {
int version,
OnConfigure onConfigure,
OnCreate onCreate,
OnVersionChange onUpgrade,
OnVersionChange onDowngrade,
OnOpen onOpen,
});