Skip to content

Define your data

Ryot stores every plugin’s data in one shared model of entities, events and relationships. Your manifest declares the shapes; Ryot stores, validates, backs up and queries the data for you. This page extends the Houseplants plugin from the quick start.

An entity schema is a kind of item, such as Movie, Exercise or Plant. Each entity has a name, an owner and properties that follow the schema’s propertiesSchema:

{
slug: "plant",
icon: "sun",
eventSchemas: [],
editor: { deletable: true, relationships: [] },
name: catalogMessage("entity-schema.plant.name"),
propertiesSchema: {
fields: {
species: {
type: "string",
description: "The plant's species",
label: catalogMessage("property.species"),
},
wateringIntervalDays: {
type: "integer",
description: "How many days to wait between waterings",
label: catalogMessage("property.watering-interval"),
},
},
},
}

The slug is the schema’s permanent name inside your plugin. icon is one of Ryot’s built-in icon names, such as sun, house, book or dumbbell.

Each field has a type and a label, plus an optional hint that forms show under the field and a description that only developers and AI tools see. Field types include:

Type Holds
string Text. Add format: { kind: "email" }, "url" or "timezone" for those.
integer, number Whole or decimal numbers
boolean Yes or no
date, datetime A calendar day, or a moment in time
enum, enum-array One or several of a fixed list of choices
array A list of any other type, set by items
object A group of nested properties
Images and video Spread managedAssetItemSchema from @ryot-app/contract/schema/core

Add validation for rules such as { required: true } or { minimum: 0 }. The all-field-controls schema in plugins/fixture/manifest/all-field-controls.ts shows every field type in one place, and Data contracts has the full rules.

Add editor to an entity schema to let people create and edit their own entities of that type with Ryot’s built-in form. Set deletable: true to add a Delete button. Your screens open the form with EntityEditorScreen, as the quick start does.

Without an editor, entities change only through your plugin’s own code, such as an action or an import.

Every entity type that people can open also needs a screen. List it under client.entities with a detailPage, or Ryot shows “Entity page not registered”. See Screens.

An event is something that happened to an entity at a point in time, such as watching an episode or logging a set. Event schemas live inside their entity schema:

eventSchemas: [
{
slug: "watered",
propertiesSchema: { fields: {} },
name: catalogMessage("event-schema.watered.name"),
},
],

An event has its own properties, which can be empty as here. Events are written by your plugin’s backend code; Backend code adds an action that records a watered event.

A relationship schema links one entity type to another, such as an episode to its show, or a plant to the room it lives in:

relationshipSchemas: [
{
slug: "in-room",
sourceEntitySchemaSlug: "plant",
targetEntitySchemaSlug: "room",
propertiesSchema: { fields: {} },
name: catalogMessage("relationship-schema.in-room.name"),
},
],

Relationships can carry their own properties. To let people pick a room for a plant in the editor, list the relationship in the plant’s editor:

editor: { deletable: true, relationships: [{ slug: "in-room", direction: "outgoing" }] },

Relationship schemas also control how linked items are kept or cleaned up and who may write a link. See retention and userWritePolicy in the manifest reference.

Add browse.fields to an entity schema to give every list of those entities extra filters and sorts. Each field reads a value with a RyotQL expression:

import { castNumber, column, jsonPath, table } from "@ryot-app/plugin-kit/ryotql";
browse: {
fields: [
{
kind: "value",
type: "number",
key: "wateringIntervalDays",
label: catalogMessage("property.watering-interval"),
expression: castNumber(
jsonPath(column(table("entity", "subject"), "properties"), "wateringIntervalDays"),
),
},
],
},

Add a sort to a field to offer it as a sort order too. See Browse fields in the manifest reference.

savedViews adds views to your workspace’s sidebar, such as All Workouts. A view pairs a query with a layout (list, grid or table) and can offer an Add button that searches for or creates items. Views use the listPresentation and gridPresentation components you register under client.entities. Views are the most involved part of the manifest; start from plugins/fixture/manifest/saved-views.ts and the manifest reference.

The manifest reference and execution reference cover the rest, including:

  • userBootstrap: entities Ryot creates for each person when they first use the plugin.
  • memberships: relationships Ryot keeps up to date automatically, such as “is in my library”.
  • Folds: values your plugin derives from an entity’s events, which Ryot recomputes after every change.
  • calendarSources: dates that show up on the Ryot calendar.

Once your plugin is installed, an update may add entity types, properties, events and relationships, but it cannot remove or change the ones that already exist. Ryot refuses an update that would, with “The update cannot migrate this plugin’s existing schemas.” Plan your slugs and types before you share a plugin, and add a new field instead of changing an old one.