Documentation
¶
Index ¶
- type FieldKind
- type FieldTag
- type ModelStruct
- func (m *ModelStruct) Attr(attr string) (*StructField, bool)
- func (m *ModelStruct) Collection() string
- func (m *ModelStruct) Config() *config.ModelConfig
- func (m *ModelStruct) FieldByName(name string) (*StructField, bool)
- func (m *ModelStruct) Fields() (fields []*StructField)
- func (m *ModelStruct) FilterKey(fk string) (*StructField, bool)
- func (m *ModelStruct) ForeignKey(fk string) (*StructField, bool)
- func (m *ModelStruct) LanguageField() *StructField
- func (m *ModelStruct) NamerFunc() namer.Namer
- func (m *ModelStruct) Primary() *StructField
- func (m *ModelStruct) RelationField(rel string) (*StructField, bool)
- func (m *ModelStruct) SchemaName() string
- 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() []*StructField
- func (m *ModelStruct) Type() reflect.Type
- type NestedField
- type NestedStruct
- func (s *NestedStruct) Attribute() *StructField
- func (s *NestedStruct) Fields() []*NestedField
- func (s *NestedStruct) StoreGet(key string) (interface{}, bool)
- func (s *NestedStruct) StoreSet(key string, value interface{})
- func (s *NestedStruct) StructField() *StructField
- func (s *NestedStruct) Type() reflect.Type
- type OptionsSetter
- type Relationship
- type RelationshipKind
- type RelationshipOption
- type Schema
- type SchemaNamer
- type StructField
- func (s *StructField) ApiName() string
- func (s *StructField) ExtractFieldTags(fieldTag string) []*FieldTag
- func (s *StructField) FieldIndex() []int
- func (s *StructField) FieldKind() FieldKind
- func (s *StructField) IsTimePointer() bool
- func (s *StructField) ModelStruct() *ModelStruct
- func (s *StructField) Name() string
- func (s *StructField) Nested() *NestedStruct
- func (s *StructField) ReflectField() reflect.StructField
- func (s *StructField) Relationship() *Relationship
- func (s *StructField) StoreDelete(key string)
- func (s *StructField) StoreGet(key string) (interface{}, bool)
- func (s *StructField) StoreSet(key string, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type 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 )
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) NamerFunc ¶ added in v0.1.4
func (m *ModelStruct) NamerFunc() namer.Namer
NamerFunc returns the namer func used by the given model
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
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
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 ¶
Schema is the named collection of models. It may encapsulate different model's with the same model with different logic.
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) 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) 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) 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'