TinyBase logoTinyBase

getDb

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

getDb(): SQLiteDatabase
returnsSQLiteDatabase

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 {createExpoSqlitePersister} from 'tinybase/persisters/persister-expo-sqlite';
import {createStore} from 'tinybase';
import {openDatabaseSync} from 'expo-sqlite';

const db = openDatabaseSync('my.db');
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createExpoSqlitePersister(store, db, 'my_tinybase');

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

persister.destroy();

Since

v4.5.0