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.

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.

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