TinyBase logoTinyBase β

getYDoc

The getYDoc method returns the Yjs document the Store is being persisted to.

getYDoc(): Doc
returnsDoc

The Yjs document.

Example

This example creates a Persister object against a newly-created Store and then gets the Yjs document back out again.

import {Doc} from 'yjs';
import {createStore} from 'tinybase';
import {createYjsPersister} from 'tinybase/persisters/persister-yjs';

const doc = new Doc();
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createYjsPersister(store, doc);

console.log(persister.getYDoc() == doc);
// -> true

persister.destroy();

Since

v4.3.14