mysql

package
v0.0.0-...-fb1d941 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 22 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 CloneRuntimeObj

func CloneRuntimeObj(objPtr runtime.Object) (runtime.Object, 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 GetListItemObj

func GetListItemObj(listObj runtime.Object) (listPtr interface{}, itemObj runtime.Object, err error)

func GetObjKind

func GetObjKind(objPtr runtime.Object) string

func New

func New(client *dbmysql.DB, codec runtime.Codec, version string, defaultLimit int) storage.Interface

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 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) 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) 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) 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