TinyBase logoTinyBase β

getElectricClient

The getElectricClient method returns a reference to the Electric client the Store is being persisted to.

getElectricClient(): ElectricClient<any>
returnsElectricClient<any>

A reference to the Electric client.

Example

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

import {ElectricDatabase, electrify} from 'electric-sql/wa-sqlite';
import {createElectricSqlPersister} from 'tinybase/persisters/persister-electric-sql';
import {createStore} from 'tinybase';
import {schema} from './generated/client';

const electricClient = await electrify(
  await ElectricDatabase.init('electric.db', ''),
  schema,
  {url: import.meta.env.ELECTRIC_SERVICE},
);
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createElectricSqlPersister(
  store,
  electricClient,
  'my_tinybase',
);

console.log(persister.getElectricClient() == electricClient);
// -> true

persister.destroy();

Since

v4.6.0