drift_crdt library

Flutter implementation for the drift database packages.

The CrdtQueryExecutor class can be used as a drift database implementation based on the sqflite package.

Classes

Crdt
CrdtQueryExecutor
A query executor that uses sqflite internally.
Hlc
A Hybrid Logical Clock implementation. This class trades time precision for a guaranteed monotonically increasing clock in distributed systems. Inspiration: https://cse.buffalo.edu/tech-reports/2014-04.pdf
MergeError<T>
Thrown on merge errors. Contains the failed payload to help with debugging large datasets.
SqliteTransactionCrdt

Functions

generateNodeId() String
parseCrdtChangeset(Map<String, dynamic> message) CrdtChangeset
Utility function to simplify parsing untyped changesets. It performs all necessary casts to satisfy Dart's type system, and parses Hlc timestamps. Useful when receiving datasets over the wire.
queryDeleted<T, R>(T db, DelegateCallback<R> callback) Future<R>
Allows access to the deleted records using the Drift API db the database executor to query callback the callback to execute, works with transactions too.

Typedefs

CrdtChangeset = Map<String, CrdtTableChangeset>
CrdtRecord = Map<String, Object?>
CrdtTableChangeset = List<CrdtRecord>
DatabaseCreator = FutureOr<void> Function(File file)
Signature of a function that runs when a database doesn't exist on file. This can be useful to, for instance, load the database from an asset if it doesn't exist.
DelegateCallback<R> = Future<R> Function()
Query = (String, List<Object?>)