Documentation
¶
Index ¶
- Constants
- func ByteSlice2String(bs []byte) string
- func ConvertToType(v interface{}, to reflect.Type) (interface{}, error)
- func FixIDAccHeap(h *IDAccHeap, i int)
- func GetBuffer() *bytes.Buffer
- func GetFieldByName(typ reflect.Type, name string) (reflect.StructField, error)
- func GetFieldValueByName(val reflect.Value, name string) (reflect.Value, error)
- func GetUniqTypeName(typ reflect.Type) string
- func InitIDAccHeap(h *IDAccHeap)
- func JsonFieldName(field reflect.StructField) string
- func PushIDAccHeap(h *IDAccHeap, x ElemHeapIDAcc)
- func PutBuffer(b *bytes.Buffer)
- func ValidateValuer(field reflect.Value) interface{}
- type ColumnIterator
- func (iter *ColumnIterator) Cardinality() int
- func (iter *ColumnIterator) Clone() IDIterator
- func (iter *ColumnIterator) HasNext() bool
- func (iter *ColumnIterator) JumpTo(id ModelSortable) bool
- func (iter *ColumnIterator) NextID() ModelSortable
- func (iter *ColumnIterator) Range() (ModelSortable, ModelSortable)
- type Converter
- type ElemHeapIDAcc
- type ErrorForbidden
- type ErrorValidation
- type ErrorValidations
- type FieldDescription
- type GreyHole
- type IDAccHeap
- type IDIterator
- type IntersectIterator
- func (iter *IntersectIterator) Append(iterator IDIterator)
- func (iter *IntersectIterator) AppendDiff(iterator IDIterator)
- func (iter *IntersectIterator) Cardinality() int
- func (iter *IntersectIterator) Clone() IDIterator
- func (iter *IntersectIterator) HasNext() bool
- func (iter *IntersectIterator) Iter(n int) IDIterator
- func (iter *IntersectIterator) IterDiff(n int) IDIterator
- func (iter *IntersectIterator) JumpTo(id ModelSortable) bool
- func (iter *IntersectIterator) NextID() ModelSortable
- func (iter *IntersectIterator) Range() (ModelSortable, ModelSortable)
- func (iter *IntersectIterator) Size() int
- func (iter *IntersectIterator) SizeDiffs() int
- type IterColumner
- type KV
- type MergeIterator
- func (iter *MergeIterator) Cardinality() int
- func (iter *MergeIterator) Clone() IDIterator
- func (iter *MergeIterator) HasNext() bool
- func (iter *MergeIterator) JumpTo(id ModelSortable) bool
- func (iter *MergeIterator) NextID() ModelSortable
- func (iter *MergeIterator) Range() (l ModelSortable, r ModelSortable)
- type ModelDescription
- func (md ModelDescription) GetColumnByFieldName(fieldName string) (*FieldDescription, error)
- func (md ModelDescription) GetColumnByJsonName(jsonName string) (*FieldDescription, error)
- func (md ModelDescription) GetColumnsByFieldNames(fieldNames ...string) (res []*FieldDescription)
- func (md ModelDescription) GetModelType() reflect.Type
- func (md ModelDescription) GetName() string
- func (md ModelDescription) GetStoredColumnNames() (res []string)
- func (md ModelDescription) GetUniqName() string
- func (md *ModelDescription) SearchField(f *FieldDescription) int
- type ModelIndex
- type ModelObject
- func (mo ModelObject) Clear()
- func (mo *ModelObject) Close()
- func (mo ModelObject) CopyTo(dest *ModelObject)
- func (mo ModelObject) DBData() (cols []string, vals []interface{})
- func (mo ModelObject) Delete(fd *FieldDescription)
- func (mo ModelObject) Field(fd *FieldDescription) interface{}
- func (mo ModelObject) FieldCount() int
- func (mo *ModelObject) FromMap(data map[string]interface{}) error
- func (mo *ModelObject) FromStruct(src interface{}) error
- func (mo ModelObject) GetColumnsByFieldNames(fieldNames ...string) (res []*FieldDescription)
- func (mo ModelObject) IDField() interface{}
- func (mo ModelObject) MD() *ModelDescription
- func (mo ModelObject) MarshalJSON() ([]byte, error)
- func (mo ModelObject) Prepare() error
- func (mo *ModelObject) RowScan(r sqlx.ColScanner, aliases ...string) error
- func (mo ModelObject) SetField(fd *FieldDescription, val interface{}) error
- func (mo ModelObject) SetIDField(id interface{}) error
- func (mo ModelObject) String() string
- func (mo ModelObject) ToStruct(target interface{}) error
- func (mo *ModelObject) UnmarshalJSON(b []byte) error
- func (mo ModelObject) Validate() error
- func (mo ModelObject) Walk(f func(fd *FieldDescription, value interface{}))
- type ModelSortable
- type ModelTable
- func (mt *ModelTable) CreateIndex(fd *FieldDescription) *ModelIndex
- func (mt *ModelTable) DeleteIndex(fd *FieldDescription)
- func (mt *ModelTable) HasIndex(fd *FieldDescription) bool
- func (mt *ModelTable) Key(i int) ModelSortable
- func (mt *ModelTable) Len() int
- func (mt *ModelTable) MarshalJSON() ([]byte, error)
- func (mt *ModelTable) Upsert(mo ModelObject) error
- type NullType
- type Relation
- type RelationType
- type Storable
- type String
- type UUIDv4
- func (u *UUIDv4) ConvertFrom(v interface{}) error
- func (u *UUIDv4) GobDecode(data []byte) error
- func (u UUIDv4) GobEncode() ([]byte, error)
- func (u UUIDv4) IsZero() bool
- func (u UUIDv4) ModelEqual(ms ModelSortable) bool
- func (u UUIDv4) ModelLess(ms ModelSortable) bool
- func (u *UUIDv4) Scan(src interface{}) error
- func (u UUIDv4) String() string
- func (u UUIDv4) Value() (driver.Value, error)
- type ValidationErrorDesc
Constants ¶
View Source
const ( TagValidate = "validate" Tag = "store" TagName = "db" TagOptionIgnore = "-" TagOptionCascade = "cascade" TagOptionForeignKey = "foreignKey" TagOptionManyToMany = "many2many" IDField = "ID" CreatedAtField = "CreatedAt" UpdatedAtField = "UpdatedAt" DeletedAtField = "DeletedAt" )
Variables ¶
This section is empty.
Functions ¶
func ByteSlice2String ¶
func ConvertToType ¶
func FixIDAccHeap ¶
func GetFieldByName ¶
func GetFieldValueByName ¶
func GetUniqTypeName ¶
func InitIDAccHeap ¶
func InitIDAccHeap(h *IDAccHeap)
func JsonFieldName ¶
func JsonFieldName(field reflect.StructField) string
func PushIDAccHeap ¶
func PushIDAccHeap(h *IDAccHeap, x ElemHeapIDAcc)
func ValidateValuer ¶
Types ¶
type ColumnIterator ¶
type ColumnIterator struct {
// contains filtered or unexported fields
}
func NewColumnIterator ¶
func NewColumnIterator(c IterColumner, filterSkip func(idx ModelSortable) bool) *ColumnIterator
func (*ColumnIterator) Cardinality ¶
func (iter *ColumnIterator) Cardinality() int
func (*ColumnIterator) Clone ¶
func (iter *ColumnIterator) Clone() IDIterator
func (*ColumnIterator) HasNext ¶
func (iter *ColumnIterator) HasNext() bool
func (*ColumnIterator) JumpTo ¶
func (iter *ColumnIterator) JumpTo(id ModelSortable) bool
func (*ColumnIterator) NextID ¶
func (iter *ColumnIterator) NextID() ModelSortable
func (*ColumnIterator) Range ¶
func (iter *ColumnIterator) Range() (ModelSortable, ModelSortable)
type ElemHeapIDAcc ¶
type ElemHeapIDAcc struct { ID ModelSortable // Value of this element. Iterator IDIterator // Which list this element comes from. }
func PopIDAccHeap ¶
func PopIDAccHeap(h *IDAccHeap) ElemHeapIDAcc
func RemoveIDAccHeap ¶
func RemoveIDAccHeap(h *IDAccHeap, i int) ElemHeapIDAcc
type ErrorForbidden ¶
type ErrorForbidden struct {
Message string
}
func (ErrorForbidden) Error ¶
func (e ErrorForbidden) Error() string
type ErrorValidation ¶
type ErrorValidation struct { ID interface{} Type reflect.Type FieldDescription FieldDescription Validator string Param string Message string }
func (ErrorValidation) Error ¶
func (e ErrorValidation) Error() string
func (*ErrorValidation) ToDesc ¶
func (e *ErrorValidation) ToDesc() ValidationErrorDesc
type ErrorValidations ¶
type ErrorValidations []ErrorValidation
func MakeErrorValidations ¶
func MakeErrorValidations(md ModelDescription, modelID interface{}, errs validator.ValidationErrors) (ErrorValidations, error)
func (ErrorValidations) Error ¶
func (e ErrorValidations) Error() string
type FieldDescription ¶
type FieldDescription struct { Idx int // index in ModelDescription.Columns StructField reflect.StructField // reflect field ElemType reflect.Type // type of field Name string // store name JsonName string JsonOmitEmpty bool Nullable bool Skip bool IsForeignKey bool RelatedColumn *FieldDescription Relation Relation }
FieldDescription - describe a field of model
func (*FieldDescription) IsStored ¶
func (fd *FieldDescription) IsStored() bool
func (*FieldDescription) MarshalJSON ¶
func (fd *FieldDescription) MarshalJSON() ([]byte, error)
func (*FieldDescription) MarshalText ¶
func (fd *FieldDescription) MarshalText() (text []byte, err error)
func (FieldDescription) String ¶
func (fd FieldDescription) String() string
type IDAccHeap ¶
type IDAccHeap struct {
Elems []ElemHeapIDAcc
}
func NewIDAccHeap ¶
func (*IDAccHeap) Pop ¶
func (h *IDAccHeap) Pop() ElemHeapIDAcc
func (*IDAccHeap) Push ¶
func (h *IDAccHeap) Push(x ElemHeapIDAcc)
type IDIterator ¶
type IDIterator interface { HasNext() bool NextID() ModelSortable JumpTo(ModelSortable) bool Range() (ModelSortable, ModelSortable) Cardinality() int Clone() IDIterator }
type IntersectIterator ¶
type IntersectIterator struct {
// contains filtered or unexported fields
}
func NewIteratorIntersect ¶
func NewIteratorIntersect() *IntersectIterator
func (*IntersectIterator) Append ¶
func (iter *IntersectIterator) Append(iterator IDIterator)
func (*IntersectIterator) AppendDiff ¶
func (iter *IntersectIterator) AppendDiff(iterator IDIterator)
at least one iterator needed for successful difference
func (*IntersectIterator) Cardinality ¶
func (iter *IntersectIterator) Cardinality() int
func (*IntersectIterator) Clone ¶
func (iter *IntersectIterator) Clone() IDIterator
func (*IntersectIterator) HasNext ¶
func (iter *IntersectIterator) HasNext() bool
func (*IntersectIterator) Iter ¶
func (iter *IntersectIterator) Iter(n int) IDIterator
func (*IntersectIterator) IterDiff ¶
func (iter *IntersectIterator) IterDiff(n int) IDIterator
func (*IntersectIterator) JumpTo ¶
func (iter *IntersectIterator) JumpTo(id ModelSortable) bool
func (*IntersectIterator) NextID ¶
func (iter *IntersectIterator) NextID() ModelSortable
func (*IntersectIterator) Range ¶
func (iter *IntersectIterator) Range() (ModelSortable, ModelSortable)
func (*IntersectIterator) Size ¶
func (iter *IntersectIterator) Size() int
func (*IntersectIterator) SizeDiffs ¶
func (iter *IntersectIterator) SizeDiffs() int
type IterColumner ¶
type IterColumner interface { Key(i int) ModelSortable Len() int }
IterColumner must be sorted by key in ascending order
type KV ¶
type KV struct { K ModelSortable V ModelSortable // IdField in ModelTable.md }
type MergeIterator ¶
type MergeIterator struct {
// contains filtered or unexported fields
}
func NewMergeIterator ¶
func NewMergeIterator(iterators ...IDIterator) *MergeIterator
func (*MergeIterator) Cardinality ¶
func (iter *MergeIterator) Cardinality() int
func (*MergeIterator) Clone ¶
func (iter *MergeIterator) Clone() IDIterator
func (*MergeIterator) HasNext ¶
func (iter *MergeIterator) HasNext() bool
func (*MergeIterator) JumpTo ¶
func (iter *MergeIterator) JumpTo(id ModelSortable) bool
func (*MergeIterator) NextID ¶
func (iter *MergeIterator) NextID() ModelSortable
func (*MergeIterator) Range ¶
func (iter *MergeIterator) Range() (l ModelSortable, r ModelSortable)
type ModelDescription ¶
type ModelDescription struct { ModelType reflect.Type StoreName string IdField *FieldDescription CreatedAtField *FieldDescription UpdatedAtField *FieldDescription DeletedAtField *FieldDescription Columns []FieldDescription ColumnPtrs []*FieldDescription ColumnByName map[string]*FieldDescription //указатель ColumnByFieldName map[string]*FieldDescription ColumnByJsonName map[string]*FieldDescription }
Model description
func NewModelDescription ¶
func NewModelDescription(modelType reflect.Type, storeName string) (*ModelDescription, error)
Создает новую модель и заполняет поля
func (ModelDescription) GetColumnByFieldName ¶
func (md ModelDescription) GetColumnByFieldName(fieldName string) (*FieldDescription, error)
func (ModelDescription) GetColumnByJsonName ¶
func (md ModelDescription) GetColumnByJsonName(jsonName string) (*FieldDescription, error)
func (ModelDescription) GetColumnsByFieldNames ¶
func (md ModelDescription) GetColumnsByFieldNames(fieldNames ...string) (res []*FieldDescription)
func (ModelDescription) GetModelType ¶
func (md ModelDescription) GetModelType() reflect.Type
func (ModelDescription) GetName ¶
func (md ModelDescription) GetName() string
func (ModelDescription) GetStoredColumnNames ¶
func (md ModelDescription) GetStoredColumnNames() (res []string)
func (ModelDescription) GetUniqName ¶
func (md ModelDescription) GetUniqName() string
func (*ModelDescription) SearchField ¶
func (md *ModelDescription) SearchField(f *FieldDescription) int
type ModelIndex ¶
type ModelIndex struct {
// contains filtered or unexported fields
}
func NewModelIndex ¶
func NewModelIndex(capacity int) *ModelIndex
func (*ModelIndex) Delete ¶
func (mi *ModelIndex) Delete(kv KV)
func (*ModelIndex) DeleteAllForKey ¶
func (mi *ModelIndex) DeleteAllForKey(kk ModelSortable)
func (*ModelIndex) Insert ¶
func (mi *ModelIndex) Insert(kv KV)
func (*ModelIndex) Len ¶
func (mi *ModelIndex) Len() int
type ModelObject ¶
type ModelObject struct {
// contains filtered or unexported fields
}
func NewModelObject ¶
func NewModelObject(md *ModelDescription, sessionFrom ...ModelObject) ModelObject
func (ModelObject) Clear ¶
func (mo ModelObject) Clear()
func (*ModelObject) Close ¶
func (mo *ModelObject) Close()
func (ModelObject) CopyTo ¶
func (mo ModelObject) CopyTo(dest *ModelObject)
func (ModelObject) DBData ¶
func (mo ModelObject) DBData() (cols []string, vals []interface{})
func (ModelObject) Delete ¶
func (mo ModelObject) Delete(fd *FieldDescription)
func (ModelObject) Field ¶
func (mo ModelObject) Field(fd *FieldDescription) interface{}
func (ModelObject) FieldCount ¶
func (mo ModelObject) FieldCount() int
func (*ModelObject) FromMap ¶
func (mo *ModelObject) FromMap(data map[string]interface{}) error
keys = json names
func (*ModelObject) FromStruct ¶
func (mo *ModelObject) FromStruct(src interface{}) error
func (ModelObject) GetColumnsByFieldNames ¶
func (mo ModelObject) GetColumnsByFieldNames(fieldNames ...string) (res []*FieldDescription)
func (ModelObject) IDField ¶
func (mo ModelObject) IDField() interface{}
func (ModelObject) MD ¶
func (mo ModelObject) MD() *ModelDescription
func (ModelObject) MarshalJSON ¶
func (mo ModelObject) MarshalJSON() ([]byte, error)
func (ModelObject) Prepare ¶
func (mo ModelObject) Prepare() error
func (*ModelObject) RowScan ¶
func (mo *ModelObject) RowScan(r sqlx.ColScanner, aliases ...string) error
RowScan scans a single sqlx.Row into the dest ModelObject. Columns which occur more than once in the result will overwrite each other! Only one table alias (or none) is supported
func (ModelObject) SetField ¶
func (mo ModelObject) SetField(fd *FieldDescription, val interface{}) error
func (ModelObject) SetIDField ¶
func (mo ModelObject) SetIDField(id interface{}) error
func (ModelObject) String ¶
func (mo ModelObject) String() string
func (ModelObject) ToStruct ¶
func (mo ModelObject) ToStruct(target interface{}) error
target is pointer to model struct
func (*ModelObject) UnmarshalJSON ¶
func (mo *ModelObject) UnmarshalJSON(b []byte) error
func (ModelObject) Validate ¶
func (mo ModelObject) Validate() error
func (ModelObject) Walk ¶
func (mo ModelObject) Walk(f func(fd *FieldDescription, value interface{}))
type ModelSortable ¶
type ModelSortable interface { ModelLess(ModelSortable) bool ModelEqual(ModelSortable) bool }
type ModelTable ¶
type ModelTable struct {
// contains filtered or unexported fields
}
func NewModelTable ¶
func NewModelTable(md *ModelDescription, capacity int) *ModelTable
func (*ModelTable) CreateIndex ¶
func (mt *ModelTable) CreateIndex(fd *FieldDescription) *ModelIndex
func (*ModelTable) DeleteIndex ¶
func (mt *ModelTable) DeleteIndex(fd *FieldDescription)
func (*ModelTable) HasIndex ¶
func (mt *ModelTable) HasIndex(fd *FieldDescription) bool
func (*ModelTable) Len ¶
func (mt *ModelTable) Len() int
func (*ModelTable) MarshalJSON ¶
func (mt *ModelTable) MarshalJSON() ([]byte, error)
func (*ModelTable) Upsert ¶
func (mt *ModelTable) Upsert(mo ModelObject) error
type NullType ¶
type NullType struct{}
var Null NullType
func (*NullType) ConvertFrom ¶
func (NullType) MarshalJSON ¶
type Relation ¶
type Relation struct { Type RelationType ForeignKey string ManyToManyTableName string Preload bool Cascade bool }
type RelationType ¶
type RelationType int
const ( RelationTypeNotRelation RelationType = iota RelationTypeHasMany RelationTypeManyToMany RelationTypeBelongsTo RelationTypeHasOne )
type String ¶
type String string
func (String) ModelEqual ¶
func (u String) ModelEqual(ms ModelSortable) bool
type UUIDv4 ¶
func FromString ¶
func (*UUIDv4) ConvertFrom ¶
store.Converter interface, u must contain zero value before call
func (UUIDv4) ModelEqual ¶
func (u UUIDv4) ModelEqual(ms ModelSortable) bool
Click to show internal directories.
Click to hide internal directories.