models

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URLExampleData

func URLExampleData() string

URLExampleData returns the url to the example-data file.

func URLModelsYML

func URLModelsYML() string

URLModelsYML return the url to the models.yml.

func URLPermission

func URLPermission() string

URLPermission returns the url to the example-data file.

func Unmarshal

func Unmarshal(r io.Reader) (map[string]Model, error)

Unmarshal parses the content of models.yml to a datastruct.q

Types

type AttributeGenericRelation

type AttributeGenericRelation struct {
	To ToGeneric `yaml:"to"`
	// contains filtered or unexported fields
}

AttributeGenericRelation is a generic-relation or generic-relation-list field.

func (AttributeGenericRelation) List

func (r AttributeGenericRelation) List() bool

List tells, if the object is a generic-relation-list.

func (AttributeGenericRelation) ToCollections

func (r AttributeGenericRelation) ToCollections() []ToCollectionField

ToCollections returns all collection, where the generic field could point to.

type AttributeRelation

type AttributeRelation struct {
	To To `yaml:"to"`
	// contains filtered or unexported fields
}

AttributeRelation is a relation or relation-list field.

func (AttributeRelation) List

func (r AttributeRelation) List() bool

List returns true, if object is an attribute-relation-list

func (AttributeRelation) ToCollections

func (r AttributeRelation) ToCollections() []ToCollectionField

ToCollections returns the names of the collections there the attribute points to. It is allways a slice with one element.

type AttributeTemplate

type AttributeTemplate struct {
	Replacement string `yaml:"replacement_collection"`
	Fields      Field  `yaml:"fields"`
}

AttributeTemplate represents a template field.

type Field

type Field struct {
	Type string

	Template *AttributeTemplate
	Required bool
	// contains filtered or unexported fields
}

Field of a model.

func (*Field) Relation

func (f *Field) Relation() Relation

Relation returns the relation object if the Field is a relation or a template with a relation. In other cases, it returns nil.

func (*Field) RestrictionMode

func (f *Field) RestrictionMode() string

RestrictionMode returns the restriction mode the field belongs to.

func (*Field) UnmarshalYAML

func (f *Field) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes a model attribute from yaml.

type Model

type Model struct {
	Fields map[string]*Field
}

Model replresents one model from models.yml.

func (*Model) UnmarshalYAML

func (m *Model) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML decodes a yaml model to models.Model.

type Relation

type Relation interface {
	ToCollections() []ToCollectionField
	List() bool
}

Relation represents some kind of relation between fields.

type To

type To struct {
	CollectionField ToCollectionField
}

To is shows a Relation where to point to.

func (*To) UnmarshalYAML

func (t *To) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes the models.yml to a To object.

type ToCollectionField

type ToCollectionField struct {
	Collection string  `yaml:"collection"`
	ToField    ToField `yaml:"field"`
}

ToCollectionField represents a field and a collection

func (*ToCollectionField) UnmarshalYAML

func (t *ToCollectionField) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes the models.yml to a To object.

type ToField

type ToField struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
}

ToField is

func (*ToField) UnmarshalYAML

func (t *ToField) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML decodes the models.yml to a ToField object.

type ToGeneric

type ToGeneric struct {
	CollectionFields []ToCollectionField
}

ToGeneric is like a To object, but for generic relations.

func (*ToGeneric) UnmarshalYAML

func (t *ToGeneric) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML unmarshalls data to a ToGeneric object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL