getStoreValuesSchema
The getStoreValuesSchema
method returns the ValuesSchema
of the Store
as an object.
getStoreValuesSchema(): ValuesSchema
returns | ValuesSchema | A |
---|
If the Store
does not already have an explicit ValuesSchema
associated with it, the data in the Store
will be scanned to infer a new ValuesSchema
, based on the types of the Values
present. Note that, unlike the inference of Cell
values in the TablesSchema
, it is not able to determine whether a Value
should have a default or not.
Examples
This example creates a Tools
object and gets the schema of a Store
that already has a ValuesSchema
.
import {createStore} from 'tinybase';
import {createTools} from 'tinybase/tools';
const store = createStore().setValuesSchema({
open: {type: 'boolean', default: true},
employees: {type: 'number'},
});
const schema = createTools(store).getStoreValuesSchema();
console.log(schema);
// -> {open: {type: 'boolean', default: true}, employees: {type: 'number'}}
This example creates a Tools
object and infers the schema of a Store
that doesn't already have a ValuesSchema
.
import {createStore} from 'tinybase';
import {createTools} from 'tinybase/tools';
const store = createStore().setValues({open: true, employees: 3});
const schema = createTools(store).getStoreValuesSchema();
console.log(schema);
// -> {open: {type: 'boolean'}, employees: {type: 'number'}}
Since
v3.0.0