TinyBase logoTinyBase β

getSql

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

getSql(): Sql<{}>
returnsSql<{}>

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 {createPostgresPersister} from 'tinybase/persisters/persister-postgres';
import {createStore} from 'tinybase';
import postgres from 'postgres';

const sql = postgres('postgres://localhost:5432/tinybase');
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = await createPostgresPersister(store, sql, 'my_tinybase');

console.log(persister.getSql() == sql);
// -> true

persister.destroy();
await sql.end();

Since

5.2.0