feat(y-indexeddb): remove id (#2810)

This commit is contained in:
Alex Yang authored and GitHub committed 2023-06-17 13:58:48 +08:00
1 parent deeafb3a12
commit c68220166a
6 files changed
+68 -68

No files matched your search

+13 -3
View File
@@ -1,14 +1,24 @@
# @toeverything/y-indexeddb
## Features
- persistence data in indexeddb
- sub-documents support
- fully TypeScript
## Usage
```ts
import { createIndexedDBProvider, downloadBinary } from '@toeverything/y-indexeddb';
import * as Y from 'yjs';
const yDoc = new Y.Doc();
const yDoc = new Y.Doc({
// we use `guid` as unique key
guid: 'my-doc',
});
// sync yDoc with indexedDB
const provider = createIndexedDBProvider('docName', yDoc);
const provider = createIndexedDBProvider(yDoc);
provider.connect();
await provider.whenSynced.then(() => {
console.log('synced');
@@ -16,7 +26,7 @@ await provider.whenSynced.then(() => {
});
// dowload binary data from indexedDB for once
downloadBinary('docName').then(blob => {
downloadBinary(yDoc.guid).then(blob => {
if (blob !== false) {
Y.applyUpdate(yDoc, blob);
}