Documentation ¶
Overview ¶
The schema package defines types for representing the optional schema support in Origins. Schemata are defined like ordinary domains; they materialize as a composition of facts and are tracked over time. In practice this means that the semantics a set of facts must adhere to is relative to the time they are transacted. For example, if an attribute's type changes, all facts transacted before that time are unaffected. The recommended approach to handling a schema change is to perform a migration of the existing facts which involves retracting the existing facts and asserting a new set. TODO: Add functions for performing schema migrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { Domain string Name string Label string Doc string Type Type Cardinality Cardinality Unique bool }
Attribute declares descriptive and functional properties which are applied to facts in various contexts. For example, if an attribute delcares a type of integer, but the associated value in a fact is not an integer (or cannot be coerced), then the fact would fail validation.
type Cardinality ¶
type Cardinality uint8
Cardinality defines the number of values that can be set for an attribute at one time.
const ( One Cardinality = iota Many )
func (Cardinality) MarshalJSON ¶
func (c Cardinality) MarshalJSON() ([]byte, error)
func (Cardinality) String ¶
func (c Cardinality) String() string
type Schema ¶
type Schema struct { Domain string // contains filtered or unexported fields }
A Schema defines the semantics of a set of entities that are used as attributes in other domains. Schema entities define one or more of the built-in schema attributes to refine the behavior during validation.
func (*Schema) Facts ¶
Facts encodes the schema as facts. This is primarily used for programmatically creating a schema and then writing the facts to storage for later use.