Documentation
¶
Overview ¶
Package models encapsulates models structure as well as their mapping process.
Index ¶
- Constants
- func NestedStructFields(n *NestedStruct) map[string]*NestedField
- func NestedStructMarshalType(n *NestedStruct) reflect.Type
- func NestedStructSetMarshalType(n *NestedStruct, mType reflect.Type)
- func NestedStructSetSubfield(s *NestedStruct, n *NestedField)
- func NestedStructType(n *NestedStruct) reflect.Type
- type ChangeStrategy
- type Collectioner
- type DeleteStrategy
- type ErrorStrategy
- type FieldKind
- type ModelMap
- func (m *ModelMap) Get(model reflect.Type) *ModelStruct
- func (m *ModelMap) GetByCollection(collection string) *ModelStruct
- func (m *ModelMap) GetModelStruct(model interface{}) (*ModelStruct, error)
- func (m *ModelMap) ModelByName(name string) *ModelStruct
- func (m *ModelMap) Models() []*ModelStruct
- func (m *ModelMap) RegisterModels(models ...interface{}) error
- func (m *ModelMap) Set(value *ModelStruct) error
- func (m *ModelMap) SetByCollection(ms *ModelStruct)
- type ModelStruct
- func (m *ModelStruct) AllowClientID() bool
- func (m *ModelStruct) Attribute(field string) (*StructField, bool)
- func (m *ModelStruct) CheckField(field string) (sField *StructField, err errors.DetailedError)
- func (m ModelStruct) Collection() string
- func (m *ModelStruct) Config() *config.ModelConfig
- func (m *ModelStruct) FieldByName(name string) *StructField
- func (m *ModelStruct) FieldCount() int
- func (m *ModelStruct) Fields() []*StructField
- func (m *ModelStruct) FilterKey(fk string) (*StructField, bool)
- func (m *ModelStruct) ForeignKey(fk string) (*StructField, bool)
- func (m *ModelStruct) ForeignKeys() (fks []*StructField)
- func (m *ModelStruct) HasForeignRelationships() bool
- func (m ModelStruct) ID() int
- func (m *ModelStruct) IsAfterLister() bool
- func (m *ModelStruct) IsBeforeLister() bool
- func (m *ModelStruct) IsJoin() bool
- func (m *ModelStruct) LanguageField() *StructField
- func (m *ModelStruct) MaxIncludedCount() int
- func (m *ModelStruct) MaxIncludedDepth() int
- func (m *ModelStruct) NamerFunc() namer.Namer
- func (m *ModelStruct) NewReflectValueMany() reflect.Value
- func (m *ModelStruct) NewReflectValueSingle() reflect.Value
- func (m *ModelStruct) NewValueMany() interface{}
- func (m *ModelStruct) NewValueSingle() interface{}
- func (m *ModelStruct) PrimaryField() *StructField
- func (m *ModelStruct) PrimaryValues(value reflect.Value) (primaries []interface{}, err error)
- func (m *ModelStruct) RelationshipField(field string) (*StructField, bool)
- func (m *ModelStruct) RelationshipFields() (rels []*StructField)
- func (m *ModelStruct) RepositoryName() string
- func (m *ModelStruct) SetConfig(cfg *config.ModelConfig) error
- func (m *ModelStruct) SetRepositoryName(repo string)
- func (m *ModelStruct) SortScopeCount() int
- func (m *ModelStruct) StoreDelete(key interface{})
- func (m *ModelStruct) StoreGet(key interface{}) (interface{}, bool)
- func (m *ModelStruct) StoreSet(key interface{}, value interface{})
- func (m *ModelStruct) String() string
- func (m *ModelStruct) StructFields() (fields []*StructField)
- func (m ModelStruct) Type() reflect.Type
- func (m ModelStruct) UseI18n() bool
- type NestedField
- type NestedStruct
- type Relationship
- func (r *Relationship) ForeignKey() *StructField
- func (r Relationship) IsManyToMany() bool
- func (r Relationship) IsToMany() bool
- func (r Relationship) IsToOne() bool
- func (r *Relationship) JoinModel() *ModelStruct
- func (r *Relationship) Kind() RelationshipKind
- func (r *Relationship) ManyToManyForeignKey() *StructField
- func (r *Relationship) OnCreate() *Strategy
- func (r *Relationship) OnDelete() *DeleteStrategy
- func (r *Relationship) OnPatch() *Strategy
- func (r *Relationship) Struct() *ModelStruct
- type RelationshipKind
- type Strategy
- type StructField
- func (s *StructField) BaseType() reflect.Type
- func (s *StructField) CanBeSorted() bool
- func (s *StructField) FieldIndex() []int
- func (s *StructField) FieldKind() FieldKind
- func (s *StructField) FieldName() string
- func (s *StructField) FieldType() reflect.Type
- func (s *StructField) GetDereferencedType() reflect.Type
- func (s *StructField) IsArray() bool
- func (s *StructField) IsBasePtr() bool
- func (s *StructField) IsHidden() bool
- func (s *StructField) IsI18n() bool
- func (s *StructField) IsISO8601() bool
- func (s *StructField) IsLanguage() bool
- func (s *StructField) IsMap() bool
- func (s *StructField) IsNestedField() bool
- func (s *StructField) IsNestedStruct() bool
- func (s *StructField) IsNoFilter() bool
- func (s *StructField) IsOmitEmpty() bool
- func (s *StructField) IsPrimary() bool
- func (s *StructField) IsPtr() bool
- func (s *StructField) IsPtrTime() bool
- func (s *StructField) IsRelationship() bool
- func (s *StructField) IsSlice() bool
- func (s *StructField) IsSortable() bool
- func (s *StructField) IsTime() bool
- func (s *StructField) IsZeroValue(fieldValue interface{}) bool
- func (s *StructField) Name() string
- func (s *StructField) Nested() *NestedStruct
- func (s *StructField) NeuronName() string
- func (s *StructField) ReflectField() reflect.StructField
- func (s *StructField) RelatedModelStruct() *ModelStruct
- func (s *StructField) RelatedModelType() reflect.Type
- func (s *StructField) Relationship() *Relationship
- func (s *StructField) Self() *StructField
- func (s *StructField) SetRelatedModel(relModel *ModelStruct)
- func (s *StructField) SetRelationship(rel *Relationship)
- func (s *StructField) StoreDelete(key string)
- func (s *StructField) StoreGet(key string) (interface{}, bool)
- func (s *StructField) StoreSet(key string, value interface{})
- func (s *StructField) String() string
- func (s *StructField) Struct() *ModelStruct
- func (s *StructField) TagValues(tag string) url.Values
- func (s *StructField) ValueFromString(value string) (interface{}, error)
- type StructFielder
Constants ¶
const ( // FDefault is a default flag value FDefault fieldFlag = iota // FOmitEmpty is a field flag for omitting empty value. FOmitempty fieldFlag = 1 << (iota - 1) // FISO8601 is a time field flag marking it usable with IS08601 formatting. FISO8601 // FI18n is the i18n field flag. FI18n // FNoFilter is the 'no filter' field flag. FNoFilter // FLanguage is the language field flag. FLanguage // FHidden is a flag for hidden field. FHidden // FSortable is a flag used for sortable fields. FSortable // FClientID is flag used to mark field as allowable to set ClientID. FClientID // FTime is a flag used to mark field type as a Time. FTime // FMap is a flag used to mark field as a map. FMap // FPtr is a flag used to mark field as a pointer. FPtr // FArray is a flag used to mark field as an array. FArray // FSlice is a flag used to mark field as a slice. FSlice // FBasePtr is flag used to mark field as a based pointer. FBasePtr // FNestedStruct is a flag used to mark field as a nested structure. FNestedStruct // FNested is a flag used to mark field as nested. FNestedField )
field flags
Variables ¶
This section is empty.
Functions ¶
func NestedStructFields ¶
func NestedStructFields(n *NestedStruct) map[string]*NestedField
NestedStructFields gets the nested struct fields
func NestedStructMarshalType ¶
func NestedStructMarshalType(n *NestedStruct) reflect.Type
NestedStructMarshalType returns the marshal type for the provided nested struct
func NestedStructSetMarshalType ¶
func NestedStructSetMarshalType(n *NestedStruct, mType reflect.Type)
NestedStructSetMarshalType sets the nested structs marshal type
func NestedStructSetSubfield ¶
func NestedStructSetSubfield(s *NestedStruct, n *NestedField)
NestedStructSetSubfield sets the subfield for the nestedStructr
func NestedStructType ¶
func NestedStructType(n *NestedStruct) reflect.Type
NestedStructType returns the reflect.Type of the nestedStruct
Types ¶
type ChangeStrategy ¶ added in v0.2.3
type ChangeStrategy int
ChangeStrategy defines the option on how to process the relationship.
const ( SetNull ChangeStrategy = iota NoAction Cascade Restrict )
Relationship options
type Collectioner ¶
type Collectioner interface {
CollectionName() string
}
Collectioner is the interface used to get the collection name from the provided model.
type DeleteStrategy ¶ added in v0.2.3
type DeleteStrategy struct { Strategy OnChange ChangeStrategy }
DeleteStrategy is the strategy for the deletion options. The 'OnChange' varible defines how the relation should react on deletion of the root model.
type ErrorStrategy ¶ added in v0.2.3
type ErrorStrategy int
ErrorStrategy is the query strategy for given relationship field.
const ( Fail ErrorStrategy = iota Continue )
Relationship error strategies constant values, with the default set to 'fail'.
type FieldKind ¶
type FieldKind int
FieldKind is an enum that defines the following field type (i.e. 'primary', 'attribute').
const ( // UnknownType is the unsupported unknown type of the struct field. 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 // KindFilterKey is the field that is used only for special case filtering. KindFilterKey // KindNested is the field that is nested within another structfield. KindNested )
Enums for the field kind.
type ModelMap ¶
type ModelMap struct { Configs map[string]*config.ModelConfig DefaultRepository string NamerFunc namer.Namer // contains filtered or unexported fields }
ModelMap contains mapped models ( as reflect.Type ) to its ModelStruct representation.
func NewModelMap ¶
func NewModelMap(namerFunc namer.Namer, c *config.Controller) *ModelMap
NewModelMap creates new model map with default 'namerFunc' and a controller config 'c'.
func (*ModelMap) Get ¶
func (m *ModelMap) Get(model reflect.Type) *ModelStruct
Get gets the *ModelStruct for the provided 'model'.
func (*ModelMap) GetByCollection ¶
func (m *ModelMap) GetByCollection(collection string) *ModelStruct
GetByCollection gets *ModelStruct by the 'collection'.
func (*ModelMap) GetModelStruct ¶ added in v0.2.1
func (m *ModelMap) GetModelStruct(model interface{}) (*ModelStruct, error)
GetModelStruct gets the model from the model map.
func (*ModelMap) ModelByName ¶ added in v0.2.1
func (m *ModelMap) ModelByName(name string) *ModelStruct
ModelByName gets the model by it's struct name.
func (*ModelMap) Models ¶
func (m *ModelMap) Models() []*ModelStruct
Models returns all models set within given model map.
func (*ModelMap) RegisterModels ¶ added in v0.2.1
RegisterModels registers the model within the model map container.
func (*ModelMap) Set ¶
func (m *ModelMap) Set(value *ModelStruct) error
Set sets the *ModelStruct for given map. If the model already exists the function returns an error.
func (*ModelMap) SetByCollection ¶
func (m *ModelMap) SetByCollection(ms *ModelStruct)
SetByCollection sets the model by it's collection.
type ModelStruct ¶
type ModelStruct struct {
// contains filtered or unexported fields
}
ModelStruct is a computed representation of the neuron models. Contain information about the model like the collection type, distinction of the field types (primary, attributes, relationships).
func (*ModelStruct) AllowClientID ¶
func (m *ModelStruct) AllowClientID() bool
AllowClientID returns boolean if the client settable id is allowed.
func (*ModelStruct) Attribute ¶
func (m *ModelStruct) Attribute(field string) (*StructField, bool)
Attribute returns the attribute field for given string.
func (*ModelStruct) CheckField ¶
func (m *ModelStruct) CheckField(field string) (sField *StructField, err errors.DetailedError)
CheckField checks if the field exists within given modelstruct.
func (ModelStruct) Collection ¶
func (m ModelStruct) Collection() string
Collection returns model's collection name.
func (*ModelStruct) Config ¶
func (m *ModelStruct) Config() *config.ModelConfig
Config returns model's *config.ModelConfig.
func (*ModelStruct) FieldByName ¶ added in v0.2.1
func (m *ModelStruct) FieldByName(name string) *StructField
FieldByName returns field for provided name. It matches both name and neuronName.
func (*ModelStruct) FieldCount ¶
func (m *ModelStruct) FieldCount() int
FieldCount gets the field number for given model.
func (*ModelStruct) Fields ¶
func (m *ModelStruct) Fields() []*StructField
Fields returns model's fields - relationships and attributes.
func (*ModelStruct) FilterKey ¶
func (m *ModelStruct) FilterKey(fk string) (*StructField, bool)
FilterKey return model's fitler key.
func (*ModelStruct) ForeignKey ¶
func (m *ModelStruct) ForeignKey(fk string) (*StructField, bool)
ForeignKey return model's foreign key.
func (*ModelStruct) ForeignKeys ¶
func (m *ModelStruct) ForeignKeys() (fks []*StructField)
ForeignKeys return ForeignKey Structfields for the given model.
func (*ModelStruct) HasForeignRelationships ¶ added in v0.2.1
func (m *ModelStruct) HasForeignRelationships() bool
HasForeignRelationships defines if the model has any foreign relationships (not a BelongsTo relationship).
func (*ModelStruct) IsAfterLister ¶
func (m *ModelStruct) IsAfterLister() bool
IsAfterLister defines if the model implements query.AfterLister interface.
func (*ModelStruct) IsBeforeLister ¶
func (m *ModelStruct) IsBeforeLister() bool
IsBeforeLister defines if the model implements query.BeforeLister interface.
func (*ModelStruct) IsJoin ¶ added in v0.2.1
func (m *ModelStruct) IsJoin() bool
IsJoin defines if the model is a join table for the Many2Many relationship.
func (*ModelStruct) LanguageField ¶
func (m *ModelStruct) LanguageField() *StructField
LanguageField returns model's language field.
func (*ModelStruct) MaxIncludedCount ¶
func (m *ModelStruct) MaxIncludedCount() int
MaxIncludedCount gets the maximum included field number prepared for given model.
func (*ModelStruct) MaxIncludedDepth ¶ added in v0.3.0
func (m *ModelStruct) MaxIncludedDepth() int
MaxIncludedDepth gets the maximum included field depth for the queries.
func (*ModelStruct) NamerFunc ¶ added in v0.2.1
func (m *ModelStruct) NamerFunc() namer.Namer
NamerFunc returns namer func for the given Model.
func (*ModelStruct) NewReflectValueMany ¶
func (m *ModelStruct) NewReflectValueMany() reflect.Value
NewReflectValueMany creates the *[]*m.Type reflect.Value.
func (*ModelStruct) NewReflectValueSingle ¶
func (m *ModelStruct) NewReflectValueSingle() reflect.Value
NewReflectValueSingle creates and returns a model's new single value.
func (*ModelStruct) NewValueMany ¶
func (m *ModelStruct) NewValueMany() interface{}
NewValueMany creates and returns a model's new slice of pointers to values.
func (*ModelStruct) NewValueSingle ¶
func (m *ModelStruct) NewValueSingle() interface{}
NewValueSingle creates and returns new value for the given model type.
func (*ModelStruct) PrimaryField ¶
func (m *ModelStruct) PrimaryField() *StructField
PrimaryField returns model's primary struct field
func (*ModelStruct) PrimaryValues ¶
func (m *ModelStruct) PrimaryValues(value reflect.Value) (primaries []interface{}, err error)
PrimaryValues gets the primary values for the provided value.
func (*ModelStruct) RelationshipField ¶
func (m *ModelStruct) RelationshipField(field string) (*StructField, bool)
RelationshipField returns the StructField for given raw field
func (*ModelStruct) RelationshipFields ¶
func (m *ModelStruct) RelationshipFields() (rels []*StructField)
RelationshipFields return structfields that are matched as relatinoships
func (*ModelStruct) RepositoryName ¶
func (m *ModelStruct) RepositoryName() string
RepositoryName returns the repository name for given model
func (*ModelStruct) SetConfig ¶
func (m *ModelStruct) SetConfig(cfg *config.ModelConfig) error
SetConfig sets the config for given ModelStruct
func (*ModelStruct) SetRepositoryName ¶
func (m *ModelStruct) SetRepositoryName(repo string)
SetRepositoryName sets the repositoryName
func (*ModelStruct) SortScopeCount ¶
func (m *ModelStruct) SortScopeCount() int
SortScopeCount returns the count of the sort fieldsb
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.3.0
func (m *ModelStruct) String() string
String implements fmt.Stringer interface.
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) UseI18n ¶
func (m ModelStruct) UseI18n() bool
UseI18n returns the bool if the model struct uses i18n.
type NestedField ¶
type NestedField struct {
// contains filtered or unexported fields
}
NestedField is the field within the NestedStruct
func NestedStructSubField ¶
func NestedStructSubField(n *NestedStruct, field string) (*NestedField, bool)
NestedStructSubField returns the NestedStruct subfield if exists.
func NewNestedField ¶
func NewNestedField( root *NestedStruct, structFielder StructFielder, nField reflect.StructField, ) *NestedField
NewNestedField returns New NestedField
func (*NestedField) Self ¶
func (n *NestedField) Self() *StructField
Self is the relation to it's struct field
func (*NestedField) SelfNested ¶
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 NestedFieldRoot ¶
func NestedFieldRoot(n *NestedField) *NestedStruct
NestedFieldRoot returns the root of the NestedField
func NewNestedStruct ¶
func NewNestedStruct(t reflect.Type, structField StructFielder) *NestedStruct
NewNestedStruct returns new nested structure
func (*NestedStruct) Attr ¶
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() StructFielder
StructField returns nested structs related struct field
func (*NestedStruct) Type ¶
func (n *NestedStruct) Type() reflect.Type
Type returns nested struct's reflect.Type
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 ¶
func (r Relationship) IsManyToMany() bool
IsManyToMany defines if the relationship is of many to many type.
func (Relationship) IsToMany ¶
func (r Relationship) IsToMany() bool
IsToMany defines if the relationship is of to many kind.
func (Relationship) IsToOne ¶
func (r Relationship) IsToOne() bool
IsToOne defines if the relationship is of to one type.
func (*Relationship) JoinModel ¶ added in v0.2.1
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.2.1
func (r *Relationship) ManyToManyForeignKey() *StructField
ManyToManyForeignKey returns the foreign key of the many2many related model's.
func (*Relationship) OnCreate ¶ added in v0.2.3
func (r *Relationship) OnCreate() *Strategy
OnCreate gets the on create strategy for the relationship.
func (*Relationship) OnDelete ¶ added in v0.2.3
func (r *Relationship) OnDelete() *DeleteStrategy
OnDelete gets the on delete strategy for the relationship.
func (*Relationship) OnPatch ¶ added in v0.2.3
func (r *Relationship) OnPatch() *Strategy
OnPatch gets the on create strategy for the relationship.
func (*Relationship) Struct ¶
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 Strategy ¶ added in v0.2.3
type Strategy struct { QueryOrder uint OnError ErrorStrategy }
Strategy is the strategy for the relationship. It's 'QueryOrder' is the querying order for multiple strategies. It defines which strategies should be used firsts. The 'OnError' error strategy defines how the relation should react on the error occurrence while.
type StructField ¶
type StructField struct {
// contains filtered or unexported fields
}
StructField is a struct that contains all neuron specific parameters.
func NestedFieldAttr ¶
func NestedFieldAttr(n *NestedField) *StructField
NestedFieldAttr returns nested Fields Attribute
func (*StructField) BaseType ¶ added in v0.2.2
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.2.2
func (s *StructField) CanBeSorted() bool
CanBeSorted returns if the struct field can be sorted.
func (*StructField) FieldIndex ¶
func (s *StructField) FieldIndex() []int
FieldIndex - gets the field index in the given model.
func (*StructField) FieldKind ¶
func (s *StructField) FieldKind() FieldKind
FieldKind returns structFields kind.
func (*StructField) FieldName ¶
func (s *StructField) FieldName() string
FieldName returns struct fields name.
func (*StructField) FieldType ¶
func (s *StructField) FieldType() reflect.Type
FieldType returns field's reflect.Type.
func (*StructField) GetDereferencedType ¶
func (s *StructField) GetDereferencedType() reflect.Type
GetDereferencedType returns structField dereferenced type.
func (*StructField) IsArray ¶
func (s *StructField) IsArray() bool
IsArray checks if the field is an array.
func (*StructField) IsBasePtr ¶
func (s *StructField) IsBasePtr() bool
IsBasePtr checks if the field has a pointer type in the base.
func (*StructField) IsHidden ¶
func (s *StructField) IsHidden() bool
IsHidden checks if the field is hidden for marshaling processes.
func (*StructField) IsI18n ¶
func (s *StructField) IsI18n() bool
IsI18n returns flag if the struct fields is an i18n.
func (*StructField) IsISO8601 ¶ added in v0.2.2
func (s *StructField) IsISO8601() bool
IsISO8601 checks if it is a time field with ISO8601 formatting.
func (*StructField) IsLanguage ¶
func (s *StructField) IsLanguage() bool
IsLanguage checks if the field is a language type.
func (*StructField) IsMap ¶
func (s *StructField) IsMap() bool
IsMap checks if the field is of map type.
func (*StructField) IsNestedField ¶ added in v0.2.2
func (s *StructField) IsNestedField() bool
IsNestedField checks if the field is not defined within ModelStruct.
func (*StructField) IsNestedStruct ¶
func (s *StructField) IsNestedStruct() bool
IsNestedStruct checks if the field is a nested structure.
func (*StructField) IsNoFilter ¶ added in v0.2.2
func (s *StructField) IsNoFilter() bool
IsNoFilter checks wether the field uses no filter flag.
func (*StructField) IsOmitEmpty ¶
func (s *StructField) IsOmitEmpty() bool
IsOmitEmpty checks if the given field has a omitempty flag.
func (*StructField) IsPrimary ¶
func (s *StructField) IsPrimary() bool
IsPrimary checks if the field is the primary field type.
func (*StructField) IsPtr ¶
func (s *StructField) IsPtr() bool
IsPtr checks if the field is a pointer.
func (*StructField) IsPtrTime ¶ added in v0.2.2
func (s *StructField) IsPtrTime() bool
IsPtrTime checks wether the field is a base ptr time flag.
func (*StructField) IsRelationship ¶
func (s *StructField) IsRelationship() bool
IsRelationship checks if given field is a relationship.
func (*StructField) IsSlice ¶
func (s *StructField) IsSlice() bool
IsSlice checks if the field is a slice based.
func (*StructField) IsSortable ¶ added in v0.2.2
func (s *StructField) IsSortable() bool
IsSortable checks if the field has a sortable flag.
func (*StructField) IsTime ¶
func (s *StructField) IsTime() bool
IsTime checks wether the field uses time flag.
func (*StructField) IsZeroValue ¶ added in v0.2.2
func (s *StructField) IsZeroValue(fieldValue interface{}) bool
IsZeroValue checks if the provided field has Zero value.
func (*StructField) Name ¶
func (s *StructField) Name() string
Name returns the reflect.StructField Name.
func (*StructField) Nested ¶
func (s *StructField) Nested() *NestedStruct
Nested returns nested field's structure.
func (*StructField) NeuronName ¶ added in v0.2.1
func (s *StructField) NeuronName() string
NeuronName returns the NeuronName.
func (*StructField) ReflectField ¶
func (s *StructField) ReflectField() reflect.StructField
ReflectField returns structs reflect.StructField.
func (*StructField) RelatedModelStruct ¶ added in v0.2.2
func (s *StructField) RelatedModelStruct() *ModelStruct
RelatedModelStruct gets the ModelStruct of the field Type. Returns nil if the field is not a relationship.
func (*StructField) RelatedModelType ¶ added in v0.2.2
func (s *StructField) RelatedModelType() reflect.Type
RelatedModelType gets the relationship's model type. Returns nil if the field is not a relationship.
func (*StructField) Relationship ¶
func (s *StructField) Relationship() *Relationship
Relationship returns field's Relationships.
func (*StructField) Self ¶
func (s *StructField) Self() *StructField
Self returns itself. Used in the nested fields. Implements Structfielder interface.
func (*StructField) SetRelatedModel ¶
func (s *StructField) SetRelatedModel(relModel *ModelStruct)
SetRelatedModel sets the related model for the given struct field.
func (*StructField) SetRelationship ¶
func (s *StructField) SetRelationship(rel *Relationship)
SetRelationship sets the relationship value for the struct 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'.
func (*StructField) String ¶ added in v0.5.1
func (s *StructField) String() string
func (*StructField) Struct ¶
func (s *StructField) Struct() *ModelStruct
Struct returns fields modelstruct
func (*StructField) TagValues ¶
func (s *StructField) TagValues(tag string) url.Values
TagValues returns the url.Values for the specific tag.
func (*StructField) ValueFromString ¶ added in v0.5.1
func (s *StructField) ValueFromString(value string) (interface{}, error)
ValueFromString gets the string 'value' of the provided struct field.
type StructFielder ¶
type StructFielder interface {
Self() *StructField
}
StructFielder is the interfaces used for getting the pointer to itself