AFFiNE/packages/y-indexeddb
2023-07-27 16:30:09 +00:00
..
benchmark perf: use lazy load provider for IDB and SQLITE (#3351) 2023-07-25 16:56:48 +00:00
src fix: undefined allDb in firefox (#3417) 2023-07-27 16:30:09 +00:00
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json v0.7.0-canary.55 2023-07-27 07:03:07 -07: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 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 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);
  }
});