TinyBase logoTinyBase β

getPglite

The getPglite method returns a reference to the database connection the Store is being persisted to.

getPglite(): PGlite
returnsPGlite

A reference to the database connection.

Example

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

import {PGlite} from '@electric-sql/pglite';
import {createPglitePersister} from 'tinybase/persisters/persister-pglite';
import {createStore} from 'tinybase';

const pglite = await PGlite.create();
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = await createPglitePersister(
  store,
  pglite,
  'my_tinybase',
);

console.log(persister.getPglite() == pglite);
// -> true

persister.destroy();
await pglite.close();

Since

5.2.0