locorda_drift 0.5.2
locorda_drift: ^0.5.2 copied to clipboard
SQLite storage backend for Locorda using Drift ORM. Cross-platform offline storage (iOS, Android, macOS, Windows, Linux, Web) for BYOB sync engines.
locorda_drift #
Cross-platform SQLite storage for Locorda, implemented with Drift ORM. Stores RDF documents, triple indices, Hybrid Logical Clocks, and tombstone metadata — works on iOS, Android, macOS, Windows, Linux, and Web.
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.