TinyBase logoTinyBase β

getClient

The getClient method returns a reference to the database client the Store is being persisted to.

getClient(): Client
returnsClient

A reference to the database client.

Example

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

import {createClient} from '@libsql/client';
import {createLibSqlPersister} from 'tinybase/persisters/persister-libsql';
import {createStore} from 'tinybase';

const client = createClient({url: 'file:my.db'});
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createLibSqlPersister(store, client, 'my_tinybase');

console.log(persister.getClient() == client);
// -> true

persister.destroy();

Since

v4.7.0