Skip to main content
An object type is a typed noun, such as Customer or Invoice. It maps a model’s columns to properties, and names the property that keys it. Handlers, policies, analytics SQL, and agent tools all use the object’s property names.

Define an object type

ontologies/crm/sales.ts

Property types

Use t.string(), t.enum(...), t.int(), t.float(), t.bool(), t.decimal(precision, scale), t.date(), t.timestamp(), t.array(type), and t.ref("Object") for another object’s key. Chain .optional() for nullable values, and .describe(text) to document a property.
Keep an object’s id when you rename it, and chain .id(name) to keep a property’s stored name when you rename the property.

Who owns a property

Every property has one owner.
  • Source-owned properties .map() a SQL expression over the object’s model. Only the source system changes them.
  • Ontology-owned properties are .owned(). Only the ontology’s actions change them, and Tilde keeps every edit in an audited log.
An object with no source is entirely ontology-owned, and its properties need no .owned(). Actions create and delete it, such as a note or a follow-up task. Its key is always a string.
Actions cannot edit source-owned properties. To change one, an action calls the source system, and can show the expected value as pending until the source confirms it. See Pending values. A link is a relationship between two object types.
List links in ontology({ links }).

More object features

Entity resolution

The same customer often appears in several systems. A resolution matches members of different object types into one entity, with deterministic rules and optional fuzzy matching.
Each feature names a normalizer, such as email or text. List resolutions in ontology({ resolutions }).

History

Set history: true on an object to keep every change of its properties from then on, by your actions or in the source system. Add historyAt to date source-side changes with one of the object’s own timestamps.
A read declares history(Invoice) to query it. Each row records the property’s old and new value, when it changed, and whether an action or the source changed it.