mapping

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: Apache-2.0 Imports: 14 Imported by: 17

Documentation

Overview

Package mapping contains neuron models mapped structures. It defines the models, fields (with options, kinds and types), relationships and field tags.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MjrMapping is the major error classification for the mapping package.
	MjrMapping errors.Major

	// ClassInvalidFieldValue is an invalid field value class.
	ClassInvalidFieldValue errors.Class

	// MnrRepository is the minor error classification related to mapping repositories.
	MnrRepository errors.Minor
	// ClassInvalidRelationValue is the error for providing invalid relation value.
	ClassInvalidRelationValue errors.Class
	// ClassInvalidRelationField is the error for providing invalid relation field.
	ClassInvalidRelationField errors.Class
	// ClassInvalidRelationIndex is the error for providing invalid relation index.
	ClassInvalidRelationIndex errors.Class

	// MnrModel is the minor error classification related to the models.
	MnrModel errors.Minor

	// ClassModelContainer is the error classification with models mapping container.
	ClassModelContainer errors.Class
	// ClassModelDefinition is the error classification for model without fields defined.
	ClassModelDefinition errors.Class
	// ClassModelNotFound is the error classification for models that are not mapped.
	ClassModelNotFound errors.Class
	// ClassModelNotImplements is the error classification when model doesn't implement some interface.
	ClassModelNotImplements errors.Class

	// ClassInternal is the error class for internal mapping errors.
	ClassInternal errors.Class
)

Functions

func NamingCamel added in v0.15.0

func NamingCamel(raw string) string

NamingCamel is a Namer function that converts the 'TestingModelName' into the 'TestingModelName' format.

func NamingKebab added in v0.15.0

func NamingKebab(raw string) string

NamingKebab is a Namer function that converts the 'TestingModelName' into the 'testing-model-name' format.

func NamingLowerCamel added in v0.15.0

func NamingLowerCamel(raw string) string

NamingLowerCamel is a Namer function that converts the 'TestingModelName' into the 'testingModelName' format.

func NamingSnake added in v0.15.0

func NamingSnake(raw string) string

NamingSnake is a Namer function that converts the 'TestingModelName' into the 'testing_model_name' format.

func NestedStructFields added in v0.15.0

func NestedStructFields(n *NestedStruct) map[string]*NestedField

NestedStructFields gets the nested struct fields

func NestedStructMarshalType added in v0.15.0

func NestedStructMarshalType(n *NestedStruct) reflect.Type

NestedStructMarshalType returns the marshal type for the provided nested struct

func NestedStructSetMarshalType added in v0.15.0

func NestedStructSetMarshalType(n *NestedStruct, mType reflect.Type)

NestedStructSetMarshalType sets the nested structs marshal type

func NestedStructSetSubfield added in v0.15.0

func NestedStructSetSubfield(s *NestedStruct, n *NestedField)

NestedStructSetSubfield sets the subfield for the nestedStructr

func NestedStructType added in v0.15.0

func NestedStructType(n *NestedStruct) reflect.Type

NestedStructType returns the reflect.Type of the nestedStruct

func NewReflectValueMany added in v0.15.0

func NewReflectValueMany(m *ModelStruct) reflect.Value

NewReflectValueMany creates the *[]*m.Type reflect.Models.

func NewReflectValueSingle added in v0.15.0

func NewReflectValueSingle(m *ModelStruct) reflect.Value

NewReflectValueSingle creates and returns a model's new single value.

func NewValueMany added in v0.15.0

func NewValueMany(m *ModelStruct) interface{}

NewValueMany creates and returns a model's new slice of pointers to values.

func NewValueSingle added in v0.15.0

func NewValueSingle(m *ModelStruct) interface{}

NewValueSingle creates and returns new value for the given model type.

func StringValues added in v0.15.0

func StringValues(value interface{}, svalues *[]string) []string

StringValues gets the string values from the provided struct field, 'value'.

Types

type Collectioner added in v0.15.0

type Collectioner interface {
	NeuronCollectionName() string
}

Collectioner is the interface used to get the collection name from the provided model.

type FieldKind

type FieldKind int

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
	// 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
	// KindNested is the field's type that is signed as Nested.
	KindNested
)

func (FieldKind) String

func (f FieldKind) String() string

String implements fmt.Stringer interface.

type FieldSet added in v0.15.0

type FieldSet []*StructField

FieldSet is a slice of fields, with some basic search functions.

func (FieldSet) Contains added in v0.15.0

func (f FieldSet) Contains(sField *StructField) bool

Contains checks if given fieldset contains given 'sField'.

func (FieldSet) ContainsFieldName added in v0.15.0

func (f FieldSet) ContainsFieldName(fieldName string) bool

ContainsFieldName checks if a field with 'fieldName' exists in given set.

type FieldTag added in v0.1.4

type FieldTag struct {
	Key    string
	Values []string
}

FieldTag is the key: values pair for the given field struct's tag.

type Fielder added in v0.15.0

type Fielder interface {
	// GetFieldZeroValue gets 'field' zero value. A zero value is an initial - non set value.
	GetFieldZeroValue(field *StructField) (interface{}, error)
	// IsFieldZero checks if the field has zero value.
	IsFieldZero(field *StructField) (bool, error)
	// SetFieldZeroValue gets 'field' zero value. A zero value is an initial - non set value.
	SetFieldZeroValue(field *StructField) error
	// GetHashableFieldValue returns hashable field value - if the function is nil - returns nil
	// If the field is []byte it would be converted to the string.
	GetHashableFieldValue(field *StructField) (interface{}, error)
	// GetFieldValue returns 'field' value.
	GetFieldValue(field *StructField) (interface{}, error)
	// SetFieldValue sets the 'field”s 'value'. In order to set
	SetFieldValue(field *StructField, value interface{}) error
}

Fielder is the interface used to get and set model field values.

type Model added in v0.15.0

type Model interface {
	NeuronCollectionName() string
	// GetPrimaryKeyValue returns the primary key field value.
	GetPrimaryKeyValue() interface{}
	// GetPrimaryKeyZeroValue gets the primary key zero (non set) value.
	GetPrimaryKeyZeroValue() interface{}
	// IsPrimaryKeyZero checks if the primary key value is zero.
	IsPrimaryKeyZero() bool
	// SetPrimaryKeyValue sets the primary key field value to 'src'.
	SetPrimaryKeyValue(src interface{}) error
}

Model is the interface used for getting and setting model primary values.

func NewModel added in v0.15.0

func NewModel(m *ModelStruct) Model

NewModel creates new model instance.

type ModelMap added in v0.15.0

type ModelMap struct {
	Configs map[string]*config.ModelConfig

	DefaultRepository string
	NamerFunc         Namer
	// contains filtered or unexported fields
}

ModelMap contains mapped models ( as reflect.Type ) to its ModelStruct representation.

func NewModelMap added in v0.15.0

func NewModelMap(namerFunc Namer, c *config.Controller) *ModelMap

NewModelMap creates new model map with default 'namerFunc' and a controller config 'c'.

func (*ModelMap) AddModel added in v0.15.0

func (m *ModelMap) AddModel(mStruct *ModelStruct) error

AddModel sets the *ModelStruct for given map. If the model already exists the function returns an error.

func (*ModelMap) Get added in v0.15.0

func (m *ModelMap) Get(model reflect.Type) *ModelStruct

Get gets the *ModelStruct for the provided 'model'.

func (*ModelMap) GetByCollection added in v0.15.0

func (m *ModelMap) GetByCollection(collection string) *ModelStruct

GetByCollection gets *ModelStruct by the 'collection'.

func (*ModelMap) GetModelStruct added in v0.15.0

func (m *ModelMap) GetModelStruct(model interface{}) (*ModelStruct, error)

GetModelStruct gets the model from the model map.

func (*ModelMap) ModelByName added in v0.15.0

func (m *ModelMap) ModelByName(name string) *ModelStruct

ModelByName gets the model by it's struct name.

func (*ModelMap) Models added in v0.15.0

func (m *ModelMap) Models() []*ModelStruct

Models returns all models set within given model map.

func (*ModelMap) RegisterModels added in v0.15.0

func (m *ModelMap) RegisterModels(models ...interface{}) error

RegisterModels registers the model within the model map container.

type ModelStruct

type ModelStruct struct {
	// contains filtered or unexported fields
}

ModelStruct is the structure definition for the imported models. It contains all the collection name, fields, config, store and a model type.

func (*ModelStruct) AllowClientID added in v0.15.0

func (m *ModelStruct) AllowClientID() bool

AllowClientID checks if the model allows client settable primary key values.

func (*ModelStruct) Attribute added in v0.15.0

func (m *ModelStruct) Attribute(field string) (*StructField, bool)

Attribute returns the attribute for the provided ModelStruct. If the attribute doesn't exists returns nil field and false.

func (*ModelStruct) Attributes added in v0.15.0

func (m *ModelStruct) Attributes() (attributes []*StructField)

Attributes returns all field's with kind - 'KindAttribute' for given model.

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 configuration.

func (*ModelStruct) CreatedAt added in v0.15.0

func (m *ModelStruct) CreatedAt() (*StructField, bool)

CreatedAt gets the 'CreatedAt' field for the model struct.

func (*ModelStruct) DeletedAt added in v0.15.0

func (m *ModelStruct) DeletedAt() (*StructField, bool)

DeletedAt gets the 'DeletedAt' field for the model struct.

func (*ModelStruct) FieldByName

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

FieldByName returns structField by it's 'name'. It matches both reflect.StructField.Name and NeuronName.

func (*ModelStruct) Fields

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

Fields gets the model's primary, attribute and foreign key fields.

func (*ModelStruct) ForeignKey

func (m *ModelStruct) ForeignKey(fieldName string) (foreignKey *StructField, ok bool)

ForeignKey checks and returns model's foreign key field. The 'fk' foreign key field name may be a Neuron name or Golang StructField name.

func (*ModelStruct) ForeignKeys added in v0.15.0

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

ForeignKeys return ForeignKey struct fields for the given model.

func (*ModelStruct) HasForeignRelationships added in v0.15.0

func (m *ModelStruct) HasForeignRelationships() bool

HasForeignRelationships defines if the model has any foreign relationships (not a BelongsTo relationship).

func (*ModelStruct) IsJoin added in v0.15.0

func (m *ModelStruct) IsJoin() bool

IsJoin defines if the model is a join table for the Many2Many relationship.

func (*ModelStruct) MaxIncludedCount added in v0.15.0

func (m *ModelStruct) MaxIncludedCount() int

MaxIncludedCount gets the maximum included field number for given model.

func (*ModelStruct) MaxIncludedDepth added in v0.15.0

func (m *ModelStruct) MaxIncludedDepth() int

MaxIncludedDepth gets the maximum included field depth for the queries.

func (*ModelStruct) NamerFunc added in v0.1.4

func (m *ModelStruct) NamerFunc() Namer

NamerFunc returns namer func for the given Model.

func (*ModelStruct) Primary

func (m *ModelStruct) Primary() *StructField

Primary returns model's primary field StructField.

func (*ModelStruct) PrivateFields added in v0.15.0

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

PrivateFields gets model's private struct fields.

func (*ModelStruct) RelationByName added in v0.15.0

func (m *ModelStruct) RelationByName(field string) (*StructField, bool)

RelationByName gets the relationship field for the provided string The 'rel' relationship field name may be a Neuron or Golang StructField name. If the relationship field doesn't exists returns nil and false

func (*ModelStruct) RelationFields added in v0.15.0

func (m *ModelStruct) RelationFields() (relations []*StructField)

RelationFields gets all model's relationship fields.

func (*ModelStruct) SortScopeCount added in v0.15.0

func (m *ModelStruct) SortScopeCount() int

SortScopeCount returns the count of the sort fields.

func (*ModelStruct) StoreDelete

func (m *ModelStruct) StoreDelete(key interface{})

StoreDelete deletes the store's value at 'key'.

func (*ModelStruct) StoreGet

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

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

func (*ModelStruct) StoreSet

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

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

func (*ModelStruct) String added in v0.15.0

func (m *ModelStruct) String() string

String implements fmt.Stringer interface.

func (*ModelStruct) StructFieldCount added in v0.15.0

func (m *ModelStruct) StructFieldCount() int

StructFieldCount returns the number of struct fields.

func (*ModelStruct) StructFields

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

StructFields return all the StructFields used in the ModelStruct

func (*ModelStruct) Type

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

Type returns model's reflect.Type.

func (*ModelStruct) UpdatedAt added in v0.15.0

func (m *ModelStruct) UpdatedAt() (*StructField, bool)

UpdatedAt gets the 'UpdatedAt' field for the model struct.

type MultiRelationer added in v0.15.0

type MultiRelationer interface {
	// AddRelationModel adds  'model' to the given 'relation' slice.
	AddRelationModel(relation *StructField, model Model) error
	// GetRelationModels gets the model values for the 'relation' field.
	GetRelationModels(relation *StructField) ([]Model, error)
	// GetRelationModelAt gets the 'relation' single model value at 'index' in the slice.
	GetRelationModelAt(relation *StructField, index int) (Model, error)
	// GetRelationLen gets the length of the 'relation' field.
	GetRelationLen(relation *StructField) (int, error)
}

MultiRelationer is the interface used to operate on the model with relationship of 'many' type like: HasMany or Many2Many.

type Namer added in v0.15.0

type Namer func(string) string

Namer is the function that change the name with some prepared formatting.

type NestedField

type NestedField struct {
	// contains filtered or unexported fields
}

NestedField is the field within the NestedStruct

func NestedStructSubField added in v0.15.0

func NestedStructSubField(n *NestedStruct, field string) (*NestedField, bool)

NestedStructSubField returns the NestedStruct subfield if exists.

func (*NestedField) NestedAttribute added in v0.15.0

func (n *NestedField) NestedAttribute() *StructField

NestedAttribute returns nested Select Attribute

func (*NestedField) NestedFieldRoot added in v0.15.0

func (n *NestedField) NestedFieldRoot() *NestedStruct

NestedFieldRoot returns the root of the NestedField

func (*NestedField) Self added in v0.15.0

func (n *NestedField) Self() *StructField

Self is the relation to it's struct field.

func (*NestedField) SelfNested added in v0.15.0

func (n *NestedField) SelfNested() *NestedField

SelfNested returns the pointer to itself.

func (*NestedField) StructField

func (n *NestedField) StructField() *StructField

StructField returns the structField

type NestedStruct

type NestedStruct struct {
	// contains filtered or unexported fields
}

NestedStruct is the field StructField that is composed from different abstraction then the basic data types. It may contain multiple fields *NestedFields.

func (*NestedStruct) Attr added in v0.15.0

func (n *NestedStruct) Attr() *StructField

Attr returns nested struct related attribute field

func (*NestedStruct) Fields

func (n *NestedStruct) Fields() map[string]*NestedField

Fields return nested fields for the given structure

func (*NestedStruct) StructField

func (n *NestedStruct) StructField() *StructField

StructField returns nested struct fields related struct field

func (*NestedStruct) Type

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

Type returns nested struct's reflect.Type

type NestedStructFielder added in v0.15.0

type NestedStructFielder interface {
	StructFielder
	SelfNested() *NestedField
}

NestedStructFielder is the interface used for nested struct fields.

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

type OrderedFieldset []*StructField

OrderedFieldset is the wrapper over the slice of struct fields that allows to keep the fields in an ordered sorting. The sorts is based on the fields index.

func (*OrderedFieldset) Insert added in v0.15.0

func (o *OrderedFieldset) Insert(field *StructField)

Insert inserts the field into an ordered fields slice. In order to insert the field a pointer to ordered fields must be used.

func (OrderedFieldset) Len added in v0.15.0

func (o OrderedFieldset) Len() int

Len implements sort.Interface interface.

func (OrderedFieldset) Less added in v0.15.0

func (o OrderedFieldset) Less(i, j int) bool

Less implements sort.Interface interface.

func (OrderedFieldset) Swap added in v0.15.0

func (o OrderedFieldset) Swap(i, j int)

Swap implements sort.Interface interface.

type Relationship

type Relationship struct {
	// contains filtered or unexported fields
}

Relationship is the structure that contains the relation's required field's kind, join model (if exists) and the process option (onDelete, onUpdate) as well as the definition for the related model's type 'mStruct'.

func (*Relationship) ForeignKey

func (r *Relationship) ForeignKey() *StructField

ForeignKey returns relationships foreign key.

func (*Relationship) IsManyToMany added in v0.15.0

func (r *Relationship) IsManyToMany() bool

IsManyToMany defines if the relationship is of many to many type.

func (*Relationship) IsToMany added in v0.15.0

func (r *Relationship) IsToMany() bool

IsToMany defines if the relationship is of to many kind.

func (*Relationship) IsToOne added in v0.15.0

func (r *Relationship) IsToOne() bool

IsToOne defines if the relationship is of to one type.

func (*Relationship) JoinModel added in v0.15.0

func (r *Relationship) JoinModel() *ModelStruct

JoinModel returns the join model for the given many2many relationship.

func (*Relationship) Kind

func (r *Relationship) Kind() RelationshipKind

Kind returns relationship's kind.

func (*Relationship) ManyToManyForeignKey added in v0.15.0

func (r *Relationship) ManyToManyForeignKey() *StructField

ManyToManyForeignKey returns the foreign key of the many2many related model's.

func (*Relationship) Struct added in v0.15.0

func (r *Relationship) Struct() *ModelStruct

Struct returns relationship model *ModelStruct.

type RelationshipKind

type RelationshipKind int

RelationshipKind is the enum used to define the Relationship's kind.

const (
	// RelUnknown is the unknown default relationship kind. States for the relationship internal errors.
	RelUnknown RelationshipKind = iota
	// RelBelongsTo is the enum value for the 'Belongs To' relationship.
	// This relationship kind states that the model containing the relationship field
	// contains also the foreign key of the related models.
	// The foreign key is a related model's primary field.
	RelBelongsTo
	// RelHasOne is the enum value for the 'Has One' relationship.
	// This relationship kind states that the model is in a one to one relationship with
	// the related model. It also states that the foreign key is located in the related model.
	RelHasOne
	// RelHasMany is the enum value for the 'Has Many' relationship.
	// This relationship kind states that the model is in a many to one relationship with the
	// related model. It also states that the foreign key is located in the related model.
	RelHasMany
	// RelMany2Many is the enum value for the 'Many To Many' relationship.
	// This relationship kind states that the model is in a many to many relationship with the
	// related model. This relationship requires the usage of the join model structure that contains
	// foreign keys of both related model types. The 'Relationship' struct foreign key should relate to the
	// model where the related field is stored - i.e. model 'user' has relationship field 'pets' to the model 'pet'
	// then the relationship pets foreign key should be a 'user id'. In order to get the foreign key of the related model
	// the relationship has also a field 'MtmForeignKey' which should be a 'pet id'.
	RelMany2Many
)

func (RelationshipKind) String

func (r RelationshipKind) String() string

String implements fmt.Stringer interface.

type RepositoryNamer added in v0.15.0

type RepositoryNamer interface {
	RepositoryName() string
}

RepositoryNamer is the interface used for the repositories to implement that defines it's name

type SingleRelationer added in v0.15.0

type SingleRelationer interface {
	// GetRelationModel gets the model for provided 'relation' field. It is used for the single relation models
	GetRelationModel(relation *StructField) (Model, error)
	// SetRelationModel sets the 'model' value in the 'relation' field.
	SetRelationModel(relation *StructField, model Model) error
}

SingleRelationer is the interface used by the model with single relationship - HasOne or BelongsTo.

type StructField

type StructField struct {
	Index []int
	// contains filtered or unexported fields
}

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

func (*StructField) BaseType added in v0.15.0

func (s *StructField) BaseType() reflect.Type

BaseType returns the base 'reflect.Type' for the provided field. The base is the lowest possible dereference of the field's type.

func (*StructField) CanBeSorted added in v0.15.0

func (s *StructField) CanBeSorted() bool

CanBeSorted returns if the struct field can be sorted.

func (*StructField) ExtractCustomFieldTags added in v0.15.0

func (s *StructField) ExtractCustomFieldTags(fieldTag, tagSeparator, valuesSeparator string) []*FieldTag

ExtractCustomFieldTags extracts field tags from given struct field for provided 'fieldTag'. The tagSeparator and valuesSeparator are separator string value defined as follows:

	type Model struct {
		Field string `fieldTag:"subtag=value1,value2;subtag2"`
	}                     ^                  ^      ^
                    fieldTag  valueSeparator   tagSeparator

func (*StructField) ExtractFieldTags added in v0.1.4

func (s *StructField) ExtractFieldTags(fieldTag string) []*FieldTag

ExtractFieldTags extracts the []*mapping.FieldTag from the given *mapping.StructField for given StructField reflect tag.

func (*StructField) GetDereferencedType added in v0.15.0

func (s *StructField) GetDereferencedType() reflect.Type

GetDereferencedType returns structField dereferenced type.

func (*StructField) IsArray added in v0.15.0

func (s *StructField) IsArray() bool

IsArray checks if the field is an array.

func (*StructField) IsBasePtr added in v0.15.0

func (s *StructField) IsBasePtr() bool

IsBasePtr checks if the field has a pointer type in the base.

func (*StructField) IsCreatedAt added in v0.15.0

func (s *StructField) IsCreatedAt() bool

IsCreatedAt returns the boolean if the field is a 'CreatedAt' field.

func (*StructField) IsDeletedAt added in v0.15.0

func (s *StructField) IsDeletedAt() bool

IsDeletedAt returns the boolean if the field is a 'DeletedAt' field.

func (*StructField) IsField added in v0.15.0

func (s *StructField) IsField() bool

IsField checks if given struct field is a primary key, attribute or foreign key field.

func (*StructField) IsHidden added in v0.15.0

func (s *StructField) IsHidden() bool

IsHidden checks if the field is hidden for marshaling processes.

func (*StructField) IsI18n added in v0.15.0

func (s *StructField) IsI18n() bool

IsI18n returns flag if the struct fields is an i18n.

func (*StructField) IsISO8601 added in v0.15.0

func (s *StructField) IsISO8601() bool

IsISO8601 checks if it is a time field with ISO8601 formatting.

func (*StructField) IsLanguage added in v0.15.0

func (s *StructField) IsLanguage() bool

IsLanguage checks if the field is a language type.

func (*StructField) IsMap added in v0.15.0

func (s *StructField) IsMap() bool

IsMap checks if the field is of map type.

func (*StructField) IsNestedField added in v0.15.0

func (s *StructField) IsNestedField() bool

IsNestedField checks if the field is not defined within ModelStruct.

func (*StructField) IsNestedStruct added in v0.15.0

func (s *StructField) IsNestedStruct() bool

IsNestedStruct checks if the field is a nested structure.

func (*StructField) IsNoFilter added in v0.15.0

func (s *StructField) IsNoFilter() bool

IsNoFilter checks wether the field uses no filter flag.

func (*StructField) IsOmitEmpty added in v0.15.0

func (s *StructField) IsOmitEmpty() bool

IsOmitEmpty checks if the given field has a omitempty flag.

func (*StructField) IsPrimary added in v0.15.0

func (s *StructField) IsPrimary() bool

IsPrimary checks if the field is the primary field type.

func (*StructField) IsPtr added in v0.15.0

func (s *StructField) IsPtr() bool

IsPtr checks if the field is a pointer.

func (*StructField) IsRelationship added in v0.15.0

func (s *StructField) IsRelationship() bool

IsRelationship checks if given field is a relationship.

func (*StructField) IsSlice added in v0.15.0

func (s *StructField) IsSlice() bool

IsSlice checks if the field is a slice based.

func (*StructField) IsSortable added in v0.15.0

func (s *StructField) IsSortable() bool

IsSortable checks if the field has a sortable flag.

func (*StructField) IsTime added in v0.15.0

func (s *StructField) IsTime() bool

IsTime checks whether the field uses time flag.

func (*StructField) IsTimePointer

func (s *StructField) IsTimePointer() bool

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

func (*StructField) IsUpdatedAt added in v0.15.0

func (s *StructField) IsUpdatedAt() bool

IsUpdatedAt returns the boolean if the field is a 'UpdatedAt' field.

func (*StructField) IsZeroValue added in v0.15.0

func (s *StructField) IsZeroValue(fieldValue interface{}) bool

IsZeroValue checks if the provided field has Zero value.

func (*StructField) Kind added in v0.15.0

func (s *StructField) Kind() FieldKind

Kind returns struct fields kind.

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) NeuronName added in v0.15.0

func (s *StructField) NeuronName() string

NeuronName returns the field's 'api' name.

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) Self added in v0.15.0

func (s *StructField) Self() *StructField

Self returns itself. Used in the nested fields. Implements structfielder interface.

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'.

func (*StructField) String added in v0.15.0

func (s *StructField) String() string

String implements fmt.Stringer interface.

func (*StructField) Struct added in v0.15.0

func (s *StructField) Struct() *ModelStruct

Struct returns fields Model Structure.

func (*StructField) TagValues added in v0.15.0

func (s *StructField) TagValues(tag string) url.Values

TagValues returns the url.Models for the specific tag.

type StructFielder added in v0.15.0

type StructFielder interface {
	Self() *StructField
}

StructFielder is the interfaces used for getting the pointer to itself

type ZeroChecker added in v0.15.0

type ZeroChecker interface {
	IsZero() bool
	GetZero() interface{}
}

ZeroChecker is the interface that allows to check if the value is zero.

Jump to

Keyboard shortcuts

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