crdt_lf_sqlite 0.3.0
crdt_lf_sqlite: ^0.3.0 copied to clipboard
sqlite3 storage adapter for CRDT LF library objects, providing persistence for Change and Snapshot objects.
0.3.0 #
Date: 2026-09-07
Changed #
-
A change is named by its author and its clock, not by a string:
changeshasauthor,hlc_landhlc_cin place of the one text column. It is the same name written apart, so nothing is stored twice — and SQL can compare it, which is what a version vector asks. The primary key(document_id, author, hlc_l, hlc_c)is already the index that comparison wants. -
The database carries a schema version, in
PRAGMA user_version, and this build writes version- There was none before, and
CREATE TABLE IF NOT EXISTSnever reshapes an existing table, so opening a0.2.0database rebuildschanges— from its oldchange_idcolumn rather than from the stored bytes, so a change this build cannot decode still migrates. It runs in one savepoint, and every later open reads the version and returns.
- There was none before, and
-
The storages implement the shared contract from the new
crdt_lf_persistence, re-exported here so one import stays enough. Code written against a storage now runs on any adapter, andCRDTDocumentPersistencekeeps a whole document on disk for you — see that package's README. -
CRDTSqliteis now aCRDTStorageBackend.documentIdsis aUNIONover the three tables, thepeersone included, so a document that was created and never written to is still listed.close()is idempotent. -
deleteDocumentDatais nowdeleteDocument, the name the contract uses. Same behavior: the changes, the snapshots and the identity, in one transaction. -
Every storage method stays synchronous — sqlite3 answers on the spot, and the return types say so.
awaiton these calls is no longer valid, drop it. -
A transaction no longer lets another document write inside it. Savepoints are a stack on the connection, so two documents sharing one could interleave and a rollback would silently undo the other's writes. Each transaction now takes a name of its own, a synchronous body is carried through without suspending, and an asynchronous one waits for whatever is already open. A call made from inside a transaction still nests.
-
runInTransactionAsyncis gone.runInTransactiontakes aFutureOrbody and covers both. -
CRDTSqlitePeerIdStoragekeeps thePeerIda document writes under, in a newpeerstable, so a restart no longer adds a peer to the version vector. Read it before building the document:CRDTDocument(documentId: id, peerId: database.peerIdStorageForDocument(id).loadOrCreate()). An existing database picks the table up on the next open. -
getChangestakesnewerThanandupTo, bothVersionVectors. The database answers it: a change outside the range is never read and never decoded. -
CRDTDocumentStoragecomes fromcrdt_lf_persistenceand is re-exported, so the import path does not change. -
isEmptyandisNotEmptyare gone from both storages. Usecount. -
storageForDocumentreturns aCRDTSqliteDocumentStorage, whosetransaction()is a real SQLite transaction: a prune lands whole or not at all. It is built on savepoints, so a batch that opens a transaction of its own nests instead of failing on a secondBEGIN. Itsclose()does nothing — one file holds every document, so the connection staysCRDTSqlite.close()'s to release. -
Requires
crdt_lf: ^4.2.0.
0.2.0 #
Date: 2026-08-16
- Requires
crdt_lf: ^4.0.0instead of>=3.0.0 <5.0.0.
0.1.1 #
Date: 2026-07-28
- Widens the
crdt_lfconstraint to>=3.0.0 <5.0.0. No functional changes, and no migration of existing databases.
0.1.0+2 #
Date: 2026-07-19
- Documentation release: refreshes the CHANGELOG and docs published on pub.dev. No functional changes since
0.1.0.
0.1.0+1 #
Date: 2026-07-18
- Documentation release: refreshes the CHANGELOG and docs published on pub.dev. No functional changes since
0.1.0.
0.1.0 #
Initial Release #
- Added
CRDTSqliteutility class for opening a SQLite database and creating the CRDT schema - Added
CRDTSqliteChangeStorageandCRDTSqliteSnapshotStoragefor persistingChangeandSnapshotobjects as binary blobs, scoped per document via an indexeddocument_idcolumn - Added
CRDTDocumentStoragecontainer bundling both storages for a document