locorda_drift 0.5.1
locorda_drift: ^0.5.1 copied to clipboard
Locorda Drift - SQLite storage implementation for locorda_core
locorda_drift #
Drift (SQLite) storage implementation for locorda_core.
Overview #
This package provides a concrete implementation of the Storage interface from locorda_core using Drift ORM for cross-platform SQLite storage.
Features #
- Cross-platform SQLite storage - Works on iOS, Android, Web, Windows, macOS, Linux
- Document + Triple storage - Stores RDF as both complete documents and queryable triples
- CRDT metadata support - Dedicated tables for Hybrid Logical Clocks and tombstones
- Index optimization - Efficient storage for sync performance indices
- Type-safe queries - Generated Drift APIs for compile-time safety
Database Schema #
The schema is defined as Drift table classes in lib/src/sync_database.dart. Drift generates the corresponding SQL DDL at build time.
Usage #
Main thread #
import 'package:locorda/locorda.dart';
final locorda = await initLocorda(
storage: DriftMainHandler(
options: LocordaDriftNativeOptions(
databaseName: 'my_app_sync',
),
),
remotes: [...],
config: myLocordaConfig,
);
Worker thread #
import 'package:locorda/worker.dart';
Future<WorkerParams> createEngineParams(
SyncEngineConfig config,
WorkerContext context,
) async {
return WorkerParams(
storage: DriftWorkerHandler(
options: LocordaDriftNativeOptions(databaseName: 'my_app_sync'),
),
backends: [...],
);
}
See the minimal example for a complete working setup.