models

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 5 Imported by: 0

README

Models-to-go

Models-to-go is a golang package to parse the models.yml into a golang object.

The package also contains the example data in a golang map.

After the example-Data where updated, this map has to be regenerated by calling:

go generate

Documentation

Overview

Code generated with example-data.json DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var ExampleData = map[string]json.RawMessage{}/* 2092 elements not displayed */

ExampleData is a generated value from the OpenSlides example data.

It is a map from key (fqfield) to the value encoded to json.

Functions

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 added in v0.2.0

func (r AttributeGenericRelation) List() bool

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

func (AttributeGenericRelation) ToCollections added in v0.2.0

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 added in v0.2.0

func (r AttributeRelation) List() bool

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

func (AttributeRelation) ToCollections added in v0.2.0

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"`
	Fields      Field  `yaml:"fields"`
}

AttributeTemplate represents a template field.

type Field added in v0.2.0

type Field struct {
	Type string
	// contains filtered or unexported fields
}

Field of a model.

func (*Field) Relation added in v0.2.0

func (a *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) UnmarshalYAML added in v0.2.0

func (a *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 added in v0.2.0

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

ToCollectionField represents a field and a collection

func (*ToCollectionField) UnmarshalYAML added in v0.2.0

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 added in v0.2.0

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

UnmarshalYAML unmarshalls data to a ToGeneric object.

Directories

Path Synopsis
This tool generates the example data by loading the json file from the openslides repo.
This tool generates the example data by loading the json file from the openslides repo.

Jump to

Keyboard shortcuts

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