TinyBase logoTinyBase

getStorageName

The getStorageName method returns the unique key of the storage location the Store is being persisted to.

getStorageName(): string
returnsstring

The unique key of the storage location.

Example

This example creates a Persister object against a newly-created Store and then gets the unique key of the storage location back out again.

import {MMKV} from 'react-native-mmkv';
import {createStore} from 'tinybase';
import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';

const storage = new MMKV();
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createReactNativeMmkvPersister(
  store,
  storage,
  'my_tinybase',
);
console.log(persister.getStorageName() == 'my_tinybase');
// -> true

await persister.destroy();

Since

v6.5.0