definition

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DataFieldTypes = []string{"int", "string", "datetime", "bool", "time.Time"}
View Source
var (
	ErrInvalidIdentifier = errors.New("Invalid identifier")
)
View Source
var LocationColumns []string = []string{
	"id",
	"parent_id",
	"main_id",
	"hierarchy",
	"depth",
	"identifier_path",
	"content_type",
	"content_id",
	"is_hidden",
	"is_invisible",
	"priority",
	"uid",
	"section",
	"p",
}
View Source
var MetaColumns = []string{"version", "name", "published", "modified", "author", "cuid"}

Functions

func GetFields

func GetFields(typePath string) (map[string]fieldtype.FieldDef, error)

Get fields based on path pattern including container, separated by / . eg. article/relations, report/step1

func Load

func Load()

func LoadDefinition

func LoadDefinition() error

LoadDefinition Load all setting in file into memory.

Types

type ContentType

type ContentType struct {
	Name          string               `json:"name"`
	TableName     string               `json:"table_name"`
	RelationData  []string             `json:"relation_data"`
	NamePattern   string               `json:"name_pattern"`
	HasVersion    bool                 `json:"has_version"`
	HasLocation   bool                 `json:"has_location"`
	HasLocationID bool                 `json:"has_location_id"` //for non-location content
	Fields        []fieldtype.FieldDef `json:"fields"`
	DataFields    []DataField          `json:"data_fields"`
	//All fields where identifier is the key.
	FieldMap            map[string]fieldtype.FieldDef `json:"-"`
	FieldIdentifierList []string                      `json:"-"`
	// contains filtered or unexported fields
}

func GetDefinition

func GetDefinition(contentType string, language ...string) (ContentType, error)

Get a definition of a contenttype

func (*ContentType) HasDataField

func (c *ContentType) HasDataField(identifier string) bool

func (ContentType) HasRelationlist

func (c ContentType) HasRelationlist() bool

func (*ContentType) Init

func (c *ContentType) Init(fieldCallback ...func(*fieldtype.FieldDef)) error

func (*ContentType) Validate

func (c *ContentType) Validate() error

type ContentTypeList

type ContentTypeList map[string]ContentTypeMap

func GetDefinitionList

func GetDefinitionList() ContentTypeList

type ContentTypeMap

type ContentTypeMap map[string]ContentType

func (*ContentTypeMap) Init

func (c *ContentTypeMap) Init() error

type DataField

type DataField struct {
	Identifier string `json:"identifier"`
	FieldType  string `json:"fieldtype"`
	Name       string `json:"name"`
}

type VaidationRule

type VaidationRule map[string]interface{}

ValidationRule defines rule for a field's validation. eg. max length

Jump to

Keyboard shortcuts

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