Documentation ¶
Overview ¶
Package dom provides code for domain model declaration and registration.
Models are the primary focus of this package, they are used to define the bits, enum and object schema types as well as service contracts. In addition to the schema type information, models hold meta data for display, indexing, constraints and other application relevant aspects.
Models are always part of a named schema and multiple schemas are usually represented and used as a project. A model can refer to models in other previously declared schemas within a project.
Models should be used for any data that crosses environments, such as persisted data used in both the database and program environment or protocol data used to communicate between processes.
Models, schemas and projects have a JSON representations that can be sent to clients. Models can have basic validation hints, but more detailed display and form logic should always use another layer.
Easy filtering of all project parts is important for hiding irrelevant or restricted data in different environments or even on a per-connection basis to hide sensitive information for roles without permission.
Models need to describe references to establish model and schema dependencies. The project might be a good place to collect some facts about model and schema references.
Using models to describe service contracts and their arguments documents the service and lets us automatically read and route requests, and generally generate code based on it.
Index ¶
- Constants
- Variables
- func Read(r io.Reader, env exp.Env, pr *Project) error
- type Bit
- type Common
- type ConstElem
- type Elem
- type FieldElem
- type Index
- type Model
- type ModelEnv
- type ModelRef
- type ModelRels
- type Node
- type Object
- type Project
- type ProjectEnv
- type Rel
- type Relation
- type Relations
- type Schema
- type SchemaEnv
Constants ¶
const ( RelA1 Rel = 1 << iota // one a RelAN // many a RelB1 // one b RelBN // many b RelEmbed // b embedded in a RelRelax // relaxed integrity checks, b might not yet be declared RelInter // relation has an intermediate model, optionally with extra data RelReverse // reversed relation Rel11 = RelA1 | RelB1 // one a to one b Rel1N = RelA1 | RelBN // one a to many b RelN1 = RelAN | RelB1 // many a to one b RelNN = RelAN | RelBN // many a to many b RelR11 = Rel11 | RelReverse RelRN1 = Rel1N | RelReverse RelR1N = RelN1 | RelReverse RelRNN = RelNN | RelReverse )
Variables ¶
Functions ¶
Types ¶
type Elem ¶
type Elem struct { Bits Bit `json:"bits,omitempty"` Extra *lit.Dict `json:"extra,omitempty"` Ref string `json:"ref,omitempty"` }
Elem holds additional information for either constants or type paramters.
type Index ¶
type Index struct { Name string `json:"name,omitempty"` Keys []string `json:"keys"` Unique bool `json:"unique,omitempty"` }
Index represents a record model index, mainly used for databases.
type Model ¶
type Model struct { Common Type typ.Type `json:"type"` Elems []*Elem `json:"elems,omitempty"` Object *Object `json:"object,omitempty"` Schema string `json:"schema,omitempty"` }
Model represents either a bits, enum or record type and has extra domain information.
type Object ¶
type Object struct { Indices []*Index `json:"indices,omitempty"` OrderBy []string `json:"orderby,omitempty"` }
Object holds data specific to object types for grouping.
type Project ¶
Project is a collection of schemas and is the central place for any extra project configuration.
The schema definition can either be declared as part of the project file, or included from an external schema file. Includes should have syntax to filtering the included schema definition.
Extra setting, usually include, but are not limited to, targets and output paths for code generation, paths to look for the project's manifest and history.
type ProjectEnv ¶
type ProjectEnv struct { *Project // contains filtered or unexported fields }
ProjectEnv is a root environment that allows schema declaration or model resolution.
func FindEnv ¶
func FindEnv(env exp.Env) *ProjectEnv
func (*ProjectEnv) Parent ¶
func (s *ProjectEnv) Parent() exp.Env
func (*ProjectEnv) Supports ¶
func (s *ProjectEnv) Supports(x byte) bool
type Rel ¶
type Rel uint64
Rel is a bit-set describing the kind of relationship between two models referred to as a and b.
type Relations ¶
Relations maps qualified model names to a collection of all relations for that model.
type Schema ¶
type Schema struct { Common Path string `json:"path,omitempty"` Use []string `json:"use,omitempty"` Models []*Model `json:"models"` }
Schema is a namespace for models.