AFFiNE/packages/y-indexeddb
2023-09-14 06:33:47 +00:00
..
benchmark perf: use lazy load provider for IDB and SQLITE (#3351) 2023-07-25 16:56:48 +00:00
src feat: support force sync by click (#4089) 2023-09-01 01:15:07 -05:00
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json chore: bump version (#4354) 2023-09-14 06:33:47 +00:00
project.json build: enhance nx build (#2948) 2023-07-01 01:17:31 +08:00
README.md docs: update indexeddb document (#4084) 2023-08-31 17:16:27 -05:00
tsconfig.json perf: use lazy load provider for IDB and SQLITE (#3351) 2023-07-25 16:56:48 +00:00
tsconfig.node.json chore: bump typescript to 5.1.3 (#2735) 2023-06-09 11:42:54 +08:00
vite.config.ts chore: add the missing d.ts file for y-indexeddb (#3467) 2023-07-30 13:19:59 +00:00

@toeverything/y-indexeddb

Features

  • persistence data in indexeddb
  • sub-documents support
  • fully TypeScript

Usage

import { createIndexedDBProvider, downloadBinary } from '@toeverything/y-indexeddb';
import * as Y from 'yjs';

const yDoc = new Y.Doc({
  // we use `guid` as unique key
  guid: 'my-doc',
});

// sync yDoc with indexedDB
const provider = createIndexedDBProvider(yDoc);
provider.connect();
await provider.whenSynced.then(() => {
  console.log('synced');
  provider.disconnect();
});

// dowload binary data from indexedDB for once
downloadBinary(yDoc.guid).then(blob => {
  if (blob !== false) {
    Y.applyUpdate(yDoc, blob);
  }
});

LICENSE

MPL-2.0