TinyBase logoTinyBase β

getDb

The getDb method returns a reference to the database instance the Store is being persisted to.

getDb(): any
returnsany

A reference to the database instance.

Example

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

import {createSqliteWasmPersister} from 'tinybase/persisters/persister-sqlite-wasm';
import {createStore} from 'tinybase';
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';

const sqlite3 = await sqlite3InitModule();
const db = new sqlite3.oo1.DB(':memory:', 'c');
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createSqliteWasmPersister(
  store,
  sqlite3,
  db,
  'my_tinybase',
);

console.log(persister.getDb() == db);
// -> true

persister.destroy();

Since

v4.3.14