TinyBase logoTinyBase β

setValuesSchema

The setValuesSchema method lets you specify the ValuesSchema of the keyed Values part of the Store.

setValuesSchema(valuesSchema: ValuesSchema): this
TypeDescription
valuesSchemaValuesSchema

The ValuesSchema to be set for the Store.

returnsthis

A reference to the Store.

Note that this may result in a change to data in the Store, as defaults are applied or as invalid Values are removed. These changes will fire any listeners to that data, as expected.

When no longer needed, you can also completely remove an existing ValuesSchema with the delValuesSchema method.

Example

This example sets the ValuesSchema of a Store after it has been created.

import {createStore} from 'tinybase';

const store = createStore().setValuesSchema({
  open: {type: 'boolean', default: false},
});
store.setValue('open', 'maybe');

console.log(store.getValues());
// -> {open: false}

Since

v3.0.0