AFFiNE/packages/y-indexeddb
2023-08-23 19:09:40 -05:00
..
benchmark perf: use lazy load provider for IDB and SQLITE (#3351) 2023-07-25 16:56:48 +00:00
src chore: prohibit using mergeUpdates (#3701) 2023-08-11 15:55:17 +00:00
.gitignore build: perform TypeCheck for all packages (#2573) 2023-05-31 12:49:56 +00:00
package.json v0.8.0-canary.33 2023-08-23 19:09:40 -05: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 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);
  }
});