TinyBase logoTinyBase β

getSchemaJson

The getSchemaJson method returns a string serialization of both the TablesSchema and ValuesSchema of the Store.

getSchemaJson(): string
returnsstring

A string serialization of the TablesSchema and ValuesSchema of the Store.

From v3.0 onwards, the serialization is of an array with two entries. The first is the TablesSchema object, the second the ValuesSchema. In previous versions (before the existence of the ValuesSchema data structure), it was a sole object of TablesSchema.

Examples

This example serializes the TablesSchema and ValuesSchema of a Store.

import {createStore} from 'tinybase';

const store = createStore()
  .setTablesSchema({
    pets: {
      price: {type: 'number'},
    },
  })
  .setValuesSchema({
    open: {type: 'boolean'},
  });
console.log(store.getSchemaJson());
// -> '[{"pets":{"price":{"type":"number"}}},{"open":{"type":"boolean"}}]'

This example serializes the TablesSchema and ValuesSchema of an empty Store.

import {createStore} from 'tinybase';

const store = createStore();
console.log(store.getSchemaJson());
// -> '[{},{}]'

Since

v1.0.0