JSON Schema comes to Triplit
TLDR
Triplit schemas can be exported to the JSON Schema format, allowing you to use them in a wider range of tools.
Exporting Schemas to JSON Schema
Thanks to MentalGear's very generous contribution, you can now export a Triplit schema to JSON Schema. JSON Schema is a popular standard for defining the structure of JSON data.
You can transform a Triplit schema to JSON Schema by running the following command:
npx triplit schema print --format json-schema
or programmatically by using the exportCollectionAsJSONSchema
and exportSchemaAsJSONSchema
utility functions exported by @triplit/db
.
With a Triplit schema in JSON Schema format, you can use it in any tool that supports JSON Schema, such as Ajv or convert it from JSON Schema to the format used by Zod, Typebox, and other validation libraries. A library like Superforms can consume a JSON Schema and generate forms for you.
Bug fixes and performance improvements
- Fixed a bug where
WorkerClient
logs would throw a serialization error on startup - Fixed a performance regression in the
@triplit/db
package
What's next?
Database hooks have been a long-requested feature, and we're excited to announce that they're in active development. With hooks you'll be able to listen to specific database actions and run arbitrary code in response. In the coming weeks we'll share more information and solicit feedback on the design in our discord. There's also an ongoing discussion about how Triplit may support data validation, which may influence future APIs.