mapping

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldKind

type FieldKind models.FieldKind

FieldKind is an enum that defines the following field type (i.e. 'primary', 'attribute')

const (
	// UnknownType is the undefined field kind
	UnknownType FieldKind = iota

	// KindPrimary is a 'primary' field
	KindPrimary

	// KindAttribute is an 'attribute' field
	KindAttribute

	// KindClientID is id set by client
	KindClientID

	// KindRelationshipSingle is a 'relationship' with single object
	KindRelationshipSingle

	// KindRelationshipMultiple is a 'relationship' with multiple objects
	KindRelationshipMultiple

	// KindForeignKey is the field type that is responsible for the relationships
	KindForeignKey

	// KindFilterKey is the field that is used only for special case filtering
	KindFilterKey

	// KindNested is the field's type that is signed as Nested
	KindNested
)

func (FieldKind) String

func (f FieldKind) String() string

type ModelStruct

type ModelStruct models.ModelStruct

ModelStruct is the struct definition for the imported models

func (*ModelStruct) Attr

func (m *ModelStruct) Attr(attr string) (*StructField, bool)

Attr returns the attribute for the provided ModelStruct If the attribute doesn't exists

func (*ModelStruct) Collection

func (m *ModelStruct) Collection() string

Collection returns model's collection

func (*ModelStruct) Config

func (m *ModelStruct) Config() *config.ModelConfig

Config gets the model's defined confgi.ModelConfig

func (*ModelStruct) FieldByName

func (m *ModelStruct) FieldByName(name string) (*StructField, bool)

FieldByName gets the StructField by the 'name' argument. The 'name' may be a StructField's Name or ApiName

func (*ModelStruct) Fields

func (m *ModelStruct) Fields() (fields []*StructField)

Fields gets all attributes and relationships StructFields for the Model

func (*ModelStruct) FilterKey

func (m *ModelStruct) FilterKey(fk string) (*StructField, bool)

FilterKey returns model's filter key if exists

func (*ModelStruct) ForeignKey

func (m *ModelStruct) ForeignKey(fk string) (*StructField, bool)

ForeignKey returns model's foreign key field if exists

func (*ModelStruct) LanguageField

func (m *ModelStruct) LanguageField() *StructField

LanguageField returns model's language field

func (*ModelStruct) Primary

func (m *ModelStruct) Primary() *StructField

Primary returns model's primary field

func (*ModelStruct) RelationField

func (m *ModelStruct) RelationField(rel string) (*StructField, bool)

RelationField gets the relationship field for the provided string If the relationship field doesn't exists returns nil and false

func (*ModelStruct) SchemaName

func (m *ModelStruct) SchemaName() string

SchemaName gets the model's schema

func (*ModelStruct) StoreDelete

func (m *ModelStruct) StoreDelete(key string)

StoreDelete deletes the store's value at key

func (*ModelStruct) StoreGet

func (m *ModelStruct) StoreGet(key string) (interface{}, bool)

StoreGet gets the value from the store at the key: 'key'.

func (*ModelStruct) StoreSet

func (m *ModelStruct) StoreSet(key string, value interface{})

StoreSet sets into the store the value 'value' for given 'key'

func (*ModelStruct) StructFields

func (m *ModelStruct) StructFields() []*StructField

StructFields return all struct fields used by the model

func (*ModelStruct) Type

func (m *ModelStruct) Type() reflect.Type

Type returns model struct type

type NestedField

type NestedField models.NestedField

NestedField is the nested field within the NestedStruct

func (*NestedField) StoreGet

func (s *NestedField) StoreGet(key string) (interface{}, bool)

StoreGet gets the value from the store at the key: 'key'.

func (*NestedField) StoreSet

func (s *NestedField) StoreSet(key string, value interface{})

StoreSet sets into the store the value 'value' for given 'key'

func (*NestedField) StructField

func (s *NestedField) StructField() *StructField

StructField gets the structField for provided NestedFieldvalue

type NestedStruct

type NestedStruct models.NestedStruct

NestedStruct is the structure that represtents nested attribute structure

func (*NestedStruct) Attribute

func (s *NestedStruct) Attribute() *StructField

Attribute returns the attribute on the level of the 'ModelStruct' fields

func (*NestedStruct) Fields

func (s *NestedStruct) Fields() []*NestedField

Fields returns all nested fields within the nested struct

func (*NestedStruct) StoreGet

func (s *NestedStruct) StoreGet(key string) (interface{}, bool)

StoreGet gets the value from the store at the key: 'key'.

func (*NestedStruct) StoreSet

func (s *NestedStruct) StoreSet(key string, value interface{})

StoreSet sets into the store the value 'value' for given 'key'

func (*NestedStruct) StructField

func (s *NestedStruct) StructField() *StructField

StructField returns the struct field related with the nested struct. It differs from the Attribute method. The StructField method returns StructField on any level where the nested structure is defined.

func (*NestedStruct) Type

func (s *NestedStruct) Type() reflect.Type

Type returns the reflect.Type of the model within the nested struct

type OptionsSetter

type OptionsSetter interface {
	SetOptions(field *StructField)
}

OptionsSetter is the interface used to set the options from the field's StructField Used in MODELS to prepare custom structures for the defined options.

type Relationship

type Relationship models.Relationship

func (*Relationship) ForeignKey

func (r *Relationship) ForeignKey() *StructField

ForeignKey returns foreign key for given relationship

func (*Relationship) Kind

func (r *Relationship) Kind() RelationshipKind

Kind returns relationship Kind

func (*Relationship) ModelStruct

func (r *Relationship) ModelStruct() *ModelStruct

ModelStruct returns relationships model struct - related model structure

func (*Relationship) Sync

func (r *Relationship) Sync() *bool

Sync returns the synced flag

type RelationshipKind

type RelationshipKind models.RelationshipKind
const (
	RelUnknown RelationshipKind = iota
	RelBelongsTo
	RelHasOne
	RelHasMany
	RelMany2Many
)

func (RelationshipKind) String

func (r RelationshipKind) String() string

type RelationshipOption

type RelationshipOption models.RelationshipOption
const (
	Restrict RelationshipOption = iota
	NoAction
	Cascade
	SetNull
)

type Schema

type Schema models.Schema

Schema is the named collection of models. It may encapsulate different model's with the same model with different logic.

func (*Schema) Config

func (s *Schema) Config() *config.Schema

Config gets the config.Schema

func (*Schema) Models

func (s *Schema) Models() (mStructs []*ModelStruct)

Models gets the schema defined models

type SchemaNamer

type SchemaNamer interface {
	SchemaName() string
}

SchemaNamer is the interface used for mapping the models within the controller.

type StructField

type StructField models.StructField

StructField represents a field structure with its json api parameters and model relationships.

func (*StructField) ApiName

func (s *StructField) ApiName() string

ApiName returns the field's 'api' name

func (*StructField) FieldIndex

func (s *StructField) FieldIndex() []int

FieldIndex gets the field's index

func (*StructField) FieldKind

func (s *StructField) FieldKind() FieldKind

FieldKind returns struct fields kind

func (*StructField) IsTimePointer

func (s *StructField) IsTimePointer() bool

IsTimePointer checks if the field's type is a *time.time

func (*StructField) ModelStruct

func (s *StructField) ModelStruct() *ModelStruct

ModelStruct returns field's model struct

func (*StructField) Name

func (s *StructField) Name() string

Name returns field's 'golang' name

func (*StructField) Nested

func (s *StructField) Nested() *NestedStruct

Nested returns the nested structure

func (*StructField) ReflectField

func (s *StructField) ReflectField() reflect.StructField

ReflectField returns reflect.StructField related with this StructField

func (*StructField) Relationship

func (s *StructField) Relationship() *Relationship

Relationship returns relationship for provided field

func (*StructField) StoreDelete

func (s *StructField) StoreDelete(key string)

StoreDelete deletes the store value at 'key'

func (*StructField) StoreGet

func (s *StructField) StoreGet(key string) (interface{}, bool)

StoreGet gets the value from the store at the key: 'key'.

func (*StructField) StoreSet

func (s *StructField) StoreSet(key string, value interface{})

StoreSet sets into the store the value 'value' for given 'key'

Jump to

Keyboard shortcuts

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