TinyBase logoTinyBase

getHandle

The getHandle method returns the handle of the file the Store is being persisted to.

getHandle(): FileSystemFileHandle
returnsFileSystemFileHandle

The handle of the file.

Example

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

import {createStore} from 'tinybase';
import {createOpfsPersister} from 'tinybase/persisters/persister-browser';

const opfs = await navigator.storage.getDirectory();
const handle = await opfs.getFileHandle('tinybase.json', {create: true});

const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createOpfsPersister(store, handle);

console.log(persister.getHandle().name);
// -> 'tinybase.json'

await persister.destroy();

Since

v6.7.0