Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
env:
ELECTRIC_URL: http://localhost:3000

- name: Run Cloudflare Durable Object persisted collection E2E tests
run: |
cd packages/db-cloudflare-do-sqlite-persisted-collection
pnpm test:e2e

- name: Run React Native/Expo persisted collection E2E tests
run: |
Expand Down
48 changes: 48 additions & 0 deletions packages/db-cloudflare-do-sqlite-persisted-collection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# @tanstack/db-cloudflare-do-sqlite-persisted-collection

Thin SQLite persistence for Cloudflare Durable Objects.

## Public API

- `createCloudflareDOSQLitePersistence(...)`
- `persistedCollectionOptions(...)` (re-exported from core)

## Quick start

```ts
import { createCollection } from '@tanstack/db'
import {
createCloudflareDOSQLitePersistence,
persistedCollectionOptions,
} from '@tanstack/db-cloudflare-do-sqlite-persisted-collection'

type Todo = {
id: string
title: string
completed: boolean
}

export class TodosObject extends DurableObject {
persistence = createCloudflareDOSQLitePersistence({
// Pass full storage to use native DO transaction support.
storage: this.ctx.storage,
})

todos = createCollection(
persistedCollectionOptions<Todo, string>({
id: `todos`,
getKey: (todo) => todo.id,
persistence: this.persistence,
schemaVersion: 1, // Per-collection schema version
}),
)
}
```

## Notes

- One shared persistence instance can serve multiple collections.
- Mode defaults are inferred from collection usage:
- sync config present => `sync-present-reset`
- no sync config => `sync-absent-error`
- You can still override with `schemaMismatchPolicy` if needed.
Loading