TinyBase logoTinyBase β

getPowerSync

The getPowerSync method returns a reference to the PowerSync instance the Store is being persisted to.

getPowerSync(): AbstractPowerSyncDatabase
returnsAbstractPowerSyncDatabase

A reference to the PowerSync instance.

Example

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

import {createPowerSyncPersister} from 'tinybase/persisters/persister-powersync';
import {createStore} from 'tinybase';
import {usePowerSync} from '@powersync/react';

const ps = usePowerSync();
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createPowerSyncPersister(store, ps, 'my_tinybase');

console.log(persister.getPowerSync() == ps);
// -> true

persister.destroy();

Since

v4.8.0