TinyBase logoTinyBase β

getStore

The getStore method returns a reference to the underlying Store or MergeableStore that is backing this Persister object.

getStore(): Store | MergeableStore
returnsStore | MergeableStore

A reference to the Store or MergeableStore.

Example

This example creates a Persister object against a newly-created Store and then gets its reference in order to update its data.

import {createSessionPersister} from 'tinybase/persisters/persister-browser';
import {createStore} from 'tinybase';

const persister = createSessionPersister(createStore(), 'pets');
await persister.startAutoSave();

persister.getStore().setTables({pets: {fido: {species: 'dog'}}});
// ...
console.log(sessionStorage.getItem('pets'));
// -> '[{"pets":{"fido":{"species":"dog"}}},{}]'

sessionStorage.clear();

Since

v1.0.0