Delete readmes, update docs

This commit is contained in:
Jon Staab
2025-04-09 11:17:12 -07:00
parent 3301616e7d
commit 8e585fc150
53 changed files with 1946 additions and 2468 deletions
+16 -52
View File
@@ -1,67 +1,31 @@
# Storage
The storage system provides IndexedDB persistence for stores and repositories.
It's critical to initialize this early in your application lifecycle to ensure data consistency.
Initialize this early in your application lifecycle to ensure data consistency.
```typescript
import {
initStorage,
storageAdapters,
throttled,
repository,
tracker,
relays,
handles,
freshness,
plaintext
} from '@welshman/app'
import {initStorage, defaultStorageAdapters} from '@welshman/app'
// Real world example from Coracle
const initializeStorage = async () => {
const ready = initStorage("coracle-db", 1, {
// Persist relay info
relays: {
keyPath: "url",
store: throttled(3000, relays)
// Use default storage adapters, which track important metadata events,
// relays, handles, zappers, etc.
await initStorage("my-db", 1, {
...defaultStorageAdapters,
custom: {
keyPath: "key",
init: async () => console.log(await getAll("custom")),
sync: () => {
// Set up a listener for changes, using bulkPut to save records.
// Return an unsubscribe function for cleanup
},
// Persist NIP-05 handles
handles: {
keyPath: "nip05",
store: throttled(3000, handles)
},
// Track data freshness
freshness: storageAdapters.fromObjectStore(
freshness,
{throttle: 3000}
),
// Store decrypted content
plaintext: storageAdapters.fromObjectStore(
plaintext,
{throttle: 3000}
),
// Store events and their sources
events: storageAdapters.fromRepositoryAndTracker(
repository,
tracker,
{throttle: 3000}
)
})
// Wait for storage to be ready
await ready
// App can now start loading data
}
},
})
```
The storage system:
- Persists data across page reloads
- Throttles writes for performance
- Handles store migrations
- Syncs bidirectionally
- Supports custom adapters