AFFiNE/packages/y-indexeddb
2023-07-11 12:59:12 +08:00
..
benchmark fix(y-indexeddb): test cases (#2832) 2023-06-20 22:01:47 +08:00
src refactor: simplify code (#3015) 2023-07-04 17:34:22 +00:00
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json v0.7.0-canary.40 2023-07-11 12:59:12 +08:00
project.json build: enhance nx build (#2948) 2023-07-01 01:17:31 +08:00
README.md feat(y-indexeddb): remove id (#2810) 2023-06-17 13:58:48 +08:00
tsconfig.json feat: support sub-doc feature (#2774) 2023-06-14 23:22:35 +08:00
tsconfig.node.json chore: bump typescript to 5.1.3 (#2735) 2023-06-09 11:42:54 +08:00
vite.config.ts build(y-indexeddb): fix vite config 2023-04-20 18:08:33 -05: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);
  }
});