RxDB uses JSON Schema, a format widely recognized by developers through tools like OpenAPI or Swagger. Because JSON Schema is so well-established, it integrates seamlessly with existing validators, editors, and development tooling, making schema design both simple and highly flexible.
A minimal RxDB schema might define fields, data types, and indexes in a fully declarative way. For example:
const heroSchema = {
title: 'hero schema',
version: 0,
primaryKey: 'id',
type: 'object',
properties: {
id: {
type: 'string',
maxLength: 100
},
name: {
type: 'string'
},
power: {
type: 'string'
},
age: {
type: 'number'
}
},
required: ['id', 'name']
};