TinyBase

getSchemaJson

The getSchemaJson method returns a string serialization of the Schema of the Store.

getSchemaJson(): string
returnsstring

A string serialization of the Schema of the Store.

If no Schema has been set on the Store (or if it has been removed with the delSchema method), then it will return the serialization of an empty object, {}.

Examples

This example serializes the Schema of a Store.

const store = createStore().setSchema({
  pets: {
    species: {type: 'string'},
    sold: {type: 'boolean'},
  },
});
console.log(store.getSchemaJson());
// -> '{"pets":{"species":{"type":"string"},"sold":{"type":"boolean"}}}'

This example serializes the Schema of an empty Store.

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