Draft
Conversation
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-browser-wa-sqlite-persisted-collection
@tanstack/db-ivm
@tanstack/db-react-native-sqlite-persisted-collection
@tanstack/db-sqlite-persisted-collection-core
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: +504 B (+0.46%) Total Size: 111 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 4.23 kB ℹ️ View Unchanged
|
Document the transactional metadata model for persisted collections, including row and collection metadata, query retention, and Electric resume state. Made-with: Cursor
Break the persisted sync metadata RFC into phased implementation docs covering the core API, SQLite integration, query collection, Electric collection, and required invariants tests. Made-with: Cursor
Tighten the RFC and phased plan around startup metadata reads, query-owned reconciliation, cold-row retention cleanup, replay fallback behavior, and Electric reset semantics. Made-with: Cursor
Add transactional row and collection metadata plumbing across core sync state, SQLite persistence, query collections, and Electric resume state so persisted ownership and resume metadata survive restarts. Made-with: Cursor
Buffer persisted metadata writes within wrapper transactions and dedupe concurrent collection setup so warm starts no longer trip missing sync transaction errors or collection registry races. Made-with: Cursor
fce939f to
7591ee1
Compare
Drop the RFC and phased implementation plan from the branch while leaving the local working copies in place. Made-with: Cursor
Finish the core persisted metadata follow-through so reloads, retained query ownership, and Electric resume/reset state behave correctly across startup and recovery while clarifying metadata semantics around inserts and cleanup. Made-with: Cursor
Finish the remaining persisted metadata work by adding cold-row retained query cleanup, runtime TTL expiry, stronger Electric resume identity checks, and metadata delta replay for follower recovery while keeping reload fallback for reset-like cases. Made-with: Cursor
Use the persisted JSON encoder for replay payloads so bigint and date values survive applied_tx serialization and package-level SQLite adapter tests pass under the CLI runtime. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@tanstack/db,db-sqlite-persisted-collection-core,query-db-collection, andelectric-db-collectionHow To Use
Custom sync implementations
If a collection is running on a persistence layer that supports this feature, the sync function now receives an optional
metadataAPI alongsidebegin,write,commit,markReady, andtruncate.Available operations:
metadata.row.get(key)metadata.row.set(key, value)metadata.row.delete(key)metadata.collection.get(key)metadata.collection.set(key, value)metadata.collection.delete(key)metadata.collection.list(prefix?)Behavior:
get/listare allowed before any transaction is openedbegin()/commit()write({ metadata })andmetadata.row.set()target the same row metadata storeSQLite persisted collections
persistedCollectionOptions(...)now persists both row metadata and collection metadata when used withdb-sqlite-persisted-collection-core.Typical usage looks like:
What you get automatically:
Query collections
Query collections can now retain persisted ownership metadata across restarts.
What this enables:
gcTimepersistedGcTimecan be finite or effectively indefinite for offline-first flowsElectric collections
Electric collections now persist resume metadata at collection scope when wrapped with persisted collection options.
What this enables:
offset/handleresume pointTest plan
pnpm vitest --run packages/db/tests/collection.test.tspnpm --filter @tanstack/query-db-collection exec vitest run tests/query.test.ts --coverage.enabled falsepnpm --filter @tanstack/electric-db-collection exec vitest run tests/electric.test.ts --coverage.enabled falsepnpm --filter @tanstack/db-sqlite-persisted-collection-core exec vitest run tests/persisted.test.ts tests/sqlite-core-adapter.test.ts --coverage.enabled falseNotes
cleanupQueryIfIdlewarnings.