mysql

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTable

func BuildTable(obj reflect.Value, t *Table) error

BuildTable search tag in obj return the reflect.value of tag return error if has a error

func FindTableTag

func FindTableTag(typ reflect.Type, index int, t *Table) bool

FindTableTag scan object field,extract it into TableTag

func GetActualResourceKey

func GetActualResourceKey(key string) string

func New

func New(client *dbmysql.DB, codec runtime.Codec, version string) *store

New create a mysql store

func UpdateNameWithResouceKey

func UpdateNameWithResouceKey(obj runtime.Object, name string) error

UpdateNameWithResouceKey implements metadata.name

func WithTable

func WithTable(parent context.Context, val interface{}) context.Context

WithTable returns a copy of parent in which the value associated with tablecontextKey is val.

Types

type APIObjectVersioner

type APIObjectVersioner struct{}

APIObjectVersioner implements versioning and extracting database information for objects that have an embedded ObjectMeta or ListMeta field.

func (APIObjectVersioner) ObjectResourceVersion

func (a APIObjectVersioner) ObjectResourceVersion(obj runtime.Object) (uint64, error)

ObjectResourceVersion implements Versioner

func (APIObjectVersioner) UpdateList

func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint64) error

UpdateList implements Versioner

func (APIObjectVersioner) UpdateObject

func (a APIObjectVersioner) UpdateObject(obj runtime.Object, resourceVersion uint64) error

UpdateObject implements Versioner

func (APIObjectVersioner) UpdateTypeMeta

func (a APIObjectVersioner) UpdateTypeMeta(obj runtime.Object, kind string, version string) error

UpdateTypeMeta implements kind and version

type AfterFindTable

type AfterFindTable func(tableObj reflect.Value) error

AfterFindTable find tableObj in object then call this function

type RowResult

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

func ScanRows

func ScanRows(rows *sql.Rows, t *Table, obj runtime.Object) ([]*RowResult, error)

type Table

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

Table extract table from object

func GetTable

func GetTable(ctx context.Context, obj runtime.Object) (*Table, error)

GetTable scan obj tags and get table in obj if exist

func (*Table) BaseCondition

func (t *Table) BaseCondition(dbHandle *gorm.DB, p storage.SelectionPredicate, selectionFeild []string) *gorm.DB

BaseCondition build select condition

func (*Table) ConvertFieldsValue

func (t *Table) ConvertFieldsValue(value string) (sqlValue string)

ConvertFieldsValue convert struct value to sqlvale

func (*Table) CovertRowsToObject

func (t *Table) CovertRowsToObject(row *RowResult, obj runtime.Object, table reflect.Value) error

CovertRowsToObject update table(reflect.value) into obj(runtime.Object). and Marshal obj into row(RowResult)

func (*Table) ExtractTableObj

func (t *Table) ExtractTableObj(obj runtime.Object, afterFunc AfterFindTable) error

ExtractTableObj extract table field in obj. passthrough tableObj with afterFunc

func (*Table) Fields

func (t *Table) Fields(dbHandle *gorm.DB, p storage.SelectionPredicate, selectionFeild []string) *gorm.DB

Fields build gorm select condition by storage.SelectionPredicate selectionFeild contains what field will be select for query

func (*Table) GetColumnByField

func (t *Table) GetColumnByField(filed string) (column string)

GetColumnByField get sql column name by struct filed name

func (*Table) ObjMapField

func (t *Table) ObjMapField(obj reflect.Value, field []string, ignoreConstField bool) map[string]interface{}

ObjMapField convert obj field into map by filed,if field is nil return all field if ignoreConstField==true. will ignore filed if it has const keyword

func (*Table) ObjSelectField

func (t *Table) ObjSelectField(tableObj reflect.Value) []interface{}

ObjSelectField return talbe column array

func (*Table) PageCondition

func (t *Table) PageCondition(dbHandle *gorm.DB, p storage.SelectionPredicate, totalCount uint64) *gorm.DB

PageCondition build gorm selection by PageCondition

func (*Table) SetTable

func (t *Table) SetTable(obj runtime.Object, table reflect.Value) (string, error)

SetTable find talbe field in obj. then set obj field with table value

type TableTag

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

TableTag indicate table information in current field

Jump to

Keyboard shortcuts

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