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.

const electricClient = await electrify(
  await ElectricDatabase.init('electric.db', ''),
  schema,
  {url: ELECTRIC_URL},
);
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