TinyBase logoTinyBase β

getIndexesIds

The getIndexesIds function returns a reactive object with the Ids of all Indexes objects registered in the current Provider context.

getIndexesIds(): {current: Ids}
returns{current: Ids}

A reactive object with a current Ids property.

Example

This example reads a TinyBase object from Svelte context inside a child component.

Child.svelte
<svelte:options runes={true} />

<script>
  import {getIndexesIds} from 'tinybase/ui-svelte';
</script>

{JSON.stringify(getIndexesIds().current)}
App.svelte
<svelte:options runes={true} />

<script>
  import {Provider} from 'tinybase/ui-svelte';
  import Child from './Child.svelte';

  let {indexes} = $props();
</script>

<Provider indexesById={{petIndexes: indexes}}>
  <Child />
</Provider>
import {flushSync, mount} from 'svelte';
import {createIndexes, createStore} from 'tinybase';
import App from './App.svelte';

const store = createStore().setCell('pets', 'fido', 'species', 'dog');
const indexes = createIndexes(store).setIndexDefinition(
  'bySpecies',
  'pets',
  'species',
);
const app = document.body.appendChild(document.createElement('div'));
flushSync(() => mount(App, {target: app, props: {indexes}}));
console.log(app.textContent);
// -> '["petIndexes"]'

Since

v8.1.0