Documentation
¶
Index ¶
- Constants
- func FieldAllowClientID(s *StructField) bool
- func FieldBaseType(s *StructField) reflect.Type
- func FieldInitCheckFieldType(s *StructField) error
- func FieldIsArray(s *StructField) bool
- func FieldIsBasePtr(s *StructField) bool
- func FieldIsFlag(s *StructField) bool
- func FieldIsHidden(s *StructField) bool
- func FieldIsI18n(s *StructField) bool
- func FieldIsIso8601(s *StructField) bool
- func FieldIsMap(s *StructField) bool
- func FieldIsNestedField(s *StructField) bool
- func FieldIsNestedStruct(s *StructField) bool
- func FieldIsNoFilter(s *StructField) bool
- func FieldIsOmitEmpty(s *StructField) bool
- func FieldIsPtr(s *StructField) bool
- func FieldIsPtrTime(s *StructField) bool
- func FieldIsSlice(s *StructField) bool
- func FieldIsSortable(s *StructField) bool
- func FieldIsTime(s *StructField) bool
- func FieldIsZeroValue(s *StructField, fieldValue interface{}) bool
- func FieldSetFlag(s *StructField, flag fieldFlag)
- func FieldTagValues(s *StructField, tag string) url.Values
- func FieldsRelatedModelType(s *StructField) reflect.Type
- func FieldsSetNeuronName(s *StructField, neuronName string)
- 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 Collectioner
- type FieldKind
- type ModelMap
- func (m *ModelMap) ComputeNestedIncludedCount(limit int)
- 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.Error)
- 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) 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) SchemaName() string
- func (m *ModelStruct) SetConfig(cfg *config.ModelConfig) error
- func (m *ModelStruct) SetRepositoryName(repo string)
- func (m *ModelStruct) SetSchemaName(schema string)
- func (m *ModelStruct) SortScopeCount() int
- func (m *ModelStruct) StoreDelete(key string)
- func (m *ModelStruct) StoreGet(key string) (interface{}, bool)
- func (m *ModelStruct) StoreSet(key string, value interface{})
- 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) Struct() *ModelStruct
- type RelationshipKind
- type RelationshipOption
- type StructField
- 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) IsNestedStruct() bool
- func (s *StructField) IsOmitEmpty() bool
- func (s *StructField) IsPrimary() bool
- func (s *StructField) IsPtr() bool
- func (s *StructField) IsRelationship() bool
- func (s *StructField) IsSlice() bool
- func (s *StructField) IsTime() 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) 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) Struct() *ModelStruct
- func (s *StructField) TagValues(tag string) url.Values
- 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 FieldAllowClientID ¶
func FieldAllowClientID(s *StructField) bool
FieldAllowClientID checks if the given field allow ClientID
func FieldBaseType ¶
func FieldBaseType(s *StructField) reflect.Type
FieldBaseType returns the base 'reflect.Type' for the provided field. The base is the lowest possible dereference of the field's type.
func FieldInitCheckFieldType ¶
func FieldInitCheckFieldType(s *StructField) error
FieldInitCheckFieldType initializes StructField type
func FieldIsArray ¶
func FieldIsArray(s *StructField) bool
FieldIsArray checks if the field is an array
func FieldIsBasePtr ¶
func FieldIsBasePtr(s *StructField) bool
FieldIsBasePtr checks if the field has a pointer type in the base
func FieldIsFlag ¶
func FieldIsFlag(s *StructField) bool
FieldIsFlag checks wether the field has a language flag
func FieldIsHidden ¶
func FieldIsHidden(s *StructField) bool
FieldIsHidden checks if the field has a hidden flag
func FieldIsI18n ¶
func FieldIsI18n(s *StructField) bool
FieldIsI18n checks wether the field has a i18n flag
func FieldIsIso8601 ¶
func FieldIsIso8601(s *StructField) bool
FieldIsIso8601 checks wether the field uses FIso8601 flag
func FieldIsMap ¶
func FieldIsMap(s *StructField) bool
FieldIsMap checks if the field has a fMap flag
func FieldIsNestedField ¶
func FieldIsNestedField(s *StructField) bool
FieldIsNestedField checks if the field is not defined within ModelStruct
func FieldIsNestedStruct ¶
func FieldIsNestedStruct(s *StructField) bool
FieldIsNestedStruct checks if the field is a nested structure
func FieldIsNoFilter ¶
func FieldIsNoFilter(s *StructField) bool
FieldIsNoFilter checks wether the field uses no filter flag
func FieldIsOmitEmpty ¶
func FieldIsOmitEmpty(s *StructField) bool
FieldIsOmitEmpty checks wether the field uses OmitEmpty flag
func FieldIsPtrTime ¶
func FieldIsPtrTime(s *StructField) bool
FieldIsPtrTime checks wether the field is a base ptr time flag
func FieldIsSlice ¶
func FieldIsSlice(s *StructField) bool
FieldIsSlice checks if the field is a slice based
func FieldIsSortable ¶
func FieldIsSortable(s *StructField) bool
FieldIsSortable checks if the field has a sortable flag
func FieldIsTime ¶
func FieldIsTime(s *StructField) bool
FieldIsTime checks wether the field uses time flag
func FieldIsZeroValue ¶
func FieldIsZeroValue(s *StructField, fieldValue interface{}) bool
FieldIsZeroValue checks if the provided field has Zero value.
func FieldSetFlag ¶
func FieldSetFlag(s *StructField, flag fieldFlag)
FieldSetFlag sets the provided flag for the structField
func FieldTagValues ¶
func FieldTagValues(s *StructField, tag string) url.Values
FieldTagValues gets field's tag values
func FieldsRelatedModelType ¶
func FieldsRelatedModelType(s *StructField) reflect.Type
FieldsRelatedModelType gets the relationship's model type Returns nil if the structfield is not a relationship
func FieldsSetNeuronName ¶ added in v0.2.1
func FieldsSetNeuronName(s *StructField, neuronName string)
FieldsSetNeuronName sets the field's neuronName
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 Collectioner ¶
type Collectioner interface {
CollectionName() 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 unsupported unknown type of the struct field. 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 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) ComputeNestedIncludedCount ¶ added in v0.2.1
ComputeNestedIncludedCount computes the limits for the nested included count for each model.
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 jsonapi models. Contain information about the model like the collection type, distinction of the field types (primary, attributes, relationships).
func FieldsRelatedModelStruct ¶
func FieldsRelatedModelStruct(s *StructField) *ModelStruct
FieldsRelatedModelStruct gets the ModelStruct of the field Type. Returns nil if the structField is not a relationship
func FieldsStruct ¶
func FieldsStruct(s *StructField) *ModelStruct
FieldsStruct returns field's modelStruct
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.Error)
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) 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) SchemaName ¶
func (m *ModelStruct) SchemaName() string
SchemaName returns model's schema name
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) SetSchemaName ¶
func (m *ModelStruct) SetSchemaName(schema string)
SetSchemaName sets the schema name for the given model
func (*ModelStruct) SortScopeCount ¶
func (m *ModelStruct) SortScopeCount() int
SortScopeCount returns the count of the sort fieldsb
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() (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 FieldsNested ¶
func FieldsNested(s *StructField) *NestedStruct
FieldsNested gets NestedStruct in the field
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 FieldRelationship ¶
func FieldRelationship(s *StructField) *Relationship
FieldRelationship returns the struct field relationship
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 relaitonship 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) 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 RelationshipOption ¶
type RelationshipOption int
RelationshipOption defines the option on how to process the relationship.
const ( Restrict RelationshipOption = iota NoAction Cascade SetNull )
Relationship options TODO: prepare and define relationship options
type StructField ¶
type StructField struct {
// contains filtered or unexported fields
}
StructField represents a field structure with its neuron parameters and model relationships.
func NestedFieldAttr ¶
func NestedFieldAttr(n *NestedField) *StructField
NestedFieldAttr returns nested Fields Attribute
func NestedStructAttr ¶
func NestedStructAttr(n *NestedStruct) *StructField
NestedStructAttr returns related attribute to the provided nested struct
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 has a hidden flag
func (*StructField) IsI18n ¶
func (s *StructField) IsI18n() bool
IsI18n returns flag if the struct fields is an i18n field
func (*StructField) IsIso8601 ¶
func (s *StructField) IsIso8601() bool
IsIso8601 checks wether the field uses FIso8601 flag
func (*StructField) IsLanguage ¶
func (s *StructField) IsLanguage() bool
IsLanguage checks wether the field is a language type field
func (*StructField) IsMap ¶
func (s *StructField) IsMap() bool
IsMap checks if the field has a fMap flag
func (*StructField) IsNestedStruct ¶
func (s *StructField) IsNestedStruct() bool
IsNestedStruct checks if the field is a nested structure
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) 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) IsTime ¶
func (s *StructField) IsTime() bool
IsTime checks wether the field uses time flag
func (*StructField) Name ¶
func (s *StructField) Name() string
Name returns the StructFields Golang 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 structFields NeuronName
func (*StructField) ReflectField ¶
func (s *StructField) ReflectField() reflect.StructField
ReflectField returns structs reflect.StructField
func (*StructField) Relationship ¶
func (s *StructField) Relationship() *Relationship
Relationship returns StructField'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) Struct ¶
func (s *StructField) Struct() *ModelStruct
Struct returns fields modelstruct
type StructFielder ¶
type StructFielder interface {
Self() *StructField
}
StructFielder is the interfaces used for getting the pointer to itself