base

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: BSD-3-Clause Imports: 17 Imported by: 4

Documentation

Index

Constants

View Source
const VERSION = "1.2.0"

Variables

View Source
var (
	GetMapperIds      func(string) []string
	HasMapperId       func(string) bool
	GetMapperDBhandle func(string, string, bool) DBhandle
)
View Source
var Logger = logger
View Source
var MapperPre = string(base58.EncodeForInt64(uint64(uuid.NewUUID().Int64())))

Functions

func AsBool

func AsBool(v any) bool

func AsByte

func AsByte(v any) byte

func AsBytes

func AsBytes(v any) (b []byte)

func AsFloat32

func AsFloat32(v any) float32

func AsFloat64

func AsFloat64(v any) float64

func AsInt16

func AsInt16(v any) int16

func AsInt32

func AsInt32(v any) int32

func AsInt64

func AsInt64(v any) int64

func AsInt8

func AsInt8(v any) int8

func AsString

func AsString(src any) string

func AsTime

func AsTime(v any) (r time.Time, err error)

func AsUint16

func AsUint16(v any) uint16

func AsUint32

func AsUint32(v any) uint32

func AsUint64

func AsUint64(v any) uint64

func AsUint8

func AsUint8(v any) byte

func GetValue

func GetValue(fieldType reflect.Type, src any) any

func IsBytes

func IsBytes(fieldValueVal reflect.Value) bool

func ScanValue

func ScanValue(desc reflect.Value, src any)

Types

type Col added in v1.1.2

type Col string

func (Col) Name added in v1.1.2

func (c Col) Name() string

type Column

type Column[T any] interface {
	Name() string
}

type DBType

type DBType int8

type DBhandle

type DBhandle interface {
	GetTransaction() (r Transaction, err error)

	ExecuteQueryBean(sql string, args ...any) *DataBean

	ExecuteQueryBeans(sql string, args ...any) *DataBeans

	ExecuteUpdate(sql string, args ...any) (sql.Result, error)

	ExecuteBatch(sql string, args [][]any) (r []sql.Result, err error)

	GetDBType() DBType

	GetDB() *sql.DB

	Close() error
}

type DataBean

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

func NewDataBean

func NewDataBean(length int) *DataBean

func (*DataBean) FieldByIndex

func (g *DataBean) FieldByIndex(index int) (_r *FieldBeen)

func (*DataBean) FieldByName

func (g *DataBean) FieldByName(name string) (_r *FieldBeen)

func (*DataBean) FirstField added in v1.1.1

func (g *DataBean) FirstField() *FieldBeen

func (*DataBean) GetError added in v1.1.1

func (g *DataBean) GetError() error

func (*DataBean) Len

func (g *DataBean) Len() int

func (*DataBean) Map

func (g *DataBean) Map() map[string]*FieldBeen

func (*DataBean) Put

func (g *DataBean) Put(name string, fb *FieldBeen)

func (*DataBean) Scan added in v1.1.1

func (g *DataBean) Scan(v any) (err error)

Scan copies the data from the DataBean into the provided variable 'v'. This method is typically used to transfer data out of the DataBean and into another data structure or variable.

func (*DataBean) ScanAndFree added in v1.1.2

func (g *DataBean) ScanAndFree(v any) (err error)

ScanAndFree copies the data from the DataBean into the provided variable 'v'. This method is typically used to transfer data out of the DataBean and into another data structure or variable.

After calling this method, the data in the DataBean will be recycled and should not be used anymore. It is the caller's responsibility to ensure that the DataBean is not accessed after calling Scan, as the internal data may have been cleared or reused for subsequent operations.

func (*DataBean) SetError added in v1.1.1

func (g *DataBean) SetError(err error)

func (*DataBean) String

func (g *DataBean) String() (r string)

func (*DataBean) ToBool added in v1.1.1

func (g *DataBean) ToBool() (r bool)

func (*DataBean) ToBytes added in v1.1.1

func (g *DataBean) ToBytes() (r []byte)

func (*DataBean) ToFloat64 added in v1.1.1

func (g *DataBean) ToFloat64() (r float64)

func (*DataBean) ToInt64 added in v1.1.1

func (g *DataBean) ToInt64() (r int64)

func (*DataBean) ToString added in v1.1.1

func (g *DataBean) ToString() (r string)

func (*DataBean) ToTime added in v1.1.1

func (g *DataBean) ToTime() (r time.Time)

func (*DataBean) ToUint64 added in v1.1.1

func (g *DataBean) ToUint64() (r uint64)

func (*DataBean) ValueByIndex

func (g *DataBean) ValueByIndex(index int) (_val any)

func (*DataBean) ValueByName

func (g *DataBean) ValueByName(name string) (_val any)

type DataBeans added in v1.1.1

type DataBeans struct {
	Beans []*DataBean
	// contains filtered or unexported fields
}

func (*DataBeans) GetError added in v1.1.1

func (d *DataBeans) GetError() error

func (*DataBeans) Len added in v1.1.1

func (d *DataBeans) Len() int

func (*DataBeans) Scan added in v1.1.1

func (d *DataBeans) Scan(v any) error

Scan copies the data from the DataBeans into the provided variable 'v'. This method is typically used to transfer data out of the DataBean and into another data structure or variable.

func (*DataBeans) ScanAndFree added in v1.1.2

func (d *DataBeans) ScanAndFree(v any) error

ScanAndFree copies the data from the DataBeans into the provided variable 'v'. This method is typically used to transfer data out of the DataBean and into another data structure or variable.

After calling this method, the data in the DataBeans will be recycled and should not be used anymore. It is the caller's responsibility to ensure that the DataBeans is not accessed after calling Scan, as the internal data may have been cleared or reused for subsequent operations.

func (*DataBeans) SetError added in v1.1.1

func (d *DataBeans) SetError(err error)

type Field

type Field[T any] struct {
	FieldName string
}

func (*Field[T]) Asc

func (f *Field[T]) Asc() *Sort[T]

Asc : order by 'fieldName' asc

func (*Field[T]) Avg

func (f *Field[T]) Avg() *Func[T]

Avg : avg('fieldName')

func (*Field[T]) Between

func (f *Field[T]) Between(from, to any) *Where[T]

Between : between ? and ?"

func (*Field[T]) Count

func (f *Field[T]) Count() *Func[T]

Count : count('fieldName')

func (*Field[T]) Desc

func (f *Field[T]) Desc() *Sort[T]

Desc : order by 'fieldName' desc

func (*Field[T]) Distinct

func (f *Field[T]) Distinct() *Func[T]

Distinct : distinct 'fieldName'

func (*Field[T]) EQ

func (f *Field[T]) EQ(arg any) *Where[T]

EQ : =

func (*Field[T]) GE

func (f *Field[T]) GE(arg any) *Where[T]

GE : >=

func (*Field[T]) GT

func (f *Field[T]) GT(arg any) *Where[T]

GT : >

func (*Field[T]) IN

func (f *Field[T]) IN(args ...any) *Where[T]

IN : in()

func (*Field[T]) LE

func (f *Field[T]) LE(arg any) *Where[T]

LE : <=

func (*Field[T]) LIKE

func (f *Field[T]) LIKE(arg any) *Where[T]

LIKE : like %?%

func (*Field[T]) LLIKE

func (f *Field[T]) LLIKE(arg any) *Where[T]

LLIKE : like ?%

func (*Field[T]) LT

func (f *Field[T]) LT(arg any) *Where[T]

LT : <

func (*Field[T]) Max

func (f *Field[T]) Max() *Func[T]

Max : max('fieldName')

func (*Field[T]) Min

func (f *Field[T]) Min() *Func[T]

Min : min('fieldName')

func (*Field[T]) NEQ

func (f *Field[T]) NEQ(arg any) *Where[T]

NEQ : <>

func (*Field[T]) NOTIN

func (f *Field[T]) NOTIN(args ...any) *Where[T]

NOTIN : not in()

func (*Field[T]) Name added in v1.1.1

func (f *Field[T]) Name() string

func (*Field[T]) Operation

func (f *Field[T]) Operation(qurey4SetOperation string) *Func[T]

Operation :

func (*Field[T]) RLIKE

func (f *Field[T]) RLIKE(arg any) *Where[T]

RLIKE : like %?

func (*Field[T]) Sum

func (f *Field[T]) Sum() *Func[T]

Sum : sum('fieldName')

type FieldBeen

type FieldBeen struct {
	FieldValue *any
}

func NewFieldBeen added in v1.1.1

func NewFieldBeen() *FieldBeen

func (*FieldBeen) Value

func (f *FieldBeen) Value() (r any)

func (*FieldBeen) ValueBool

func (f *FieldBeen) ValueBool() bool

func (*FieldBeen) ValueBytes

func (f *FieldBeen) ValueBytes() []byte

func (*FieldBeen) ValueFloat32

func (f *FieldBeen) ValueFloat32() float32

func (*FieldBeen) ValueFloat64

func (f *FieldBeen) ValueFloat64() float64

func (*FieldBeen) ValueInt16

func (f *FieldBeen) ValueInt16() int16

func (*FieldBeen) ValueInt32

func (f *FieldBeen) ValueInt32() int32

func (*FieldBeen) ValueInt64

func (f *FieldBeen) ValueInt64() int64

func (*FieldBeen) ValueString

func (f *FieldBeen) ValueString() string

func (*FieldBeen) ValueTime

func (f *FieldBeen) ValueTime() (t time.Time)

func (*FieldBeen) ValueUint16

func (f *FieldBeen) ValueUint16() uint16

func (*FieldBeen) ValueUint32

func (f *FieldBeen) ValueUint32() uint32

func (*FieldBeen) ValueUint64

func (f *FieldBeen) ValueUint64() uint64

type Func

type Func[T any] struct {
	FieldName  string
	FieldValue any
}

func (*Func[T]) AS

func (s *Func[T]) AS(alias Column[T]) *Func[T]

func (*Func[T]) Between

func (s *Func[T]) Between(from, to any) *Having[T]

func (*Func[T]) EQ

func (s *Func[T]) EQ(arg any) *Having[T]

func (*Func[T]) GE

func (s *Func[T]) GE(arg any) *Having[T]

func (*Func[T]) GT

func (s *Func[T]) GT(arg any) *Having[T]

func (*Func[T]) LE

func (s *Func[T]) LE(arg any) *Having[T]

func (*Func[T]) LT

func (s *Func[T]) LT(arg any) *Having[T]

func (*Func[T]) NEQ

func (s *Func[T]) NEQ(arg any) *Having[T]

func (*Func[T]) Name

func (s *Func[T]) Name() string

func (*Func[T]) Value

func (s *Func[T]) Value() any

type Having

type Having[T any] struct {
	HavingSql string
	Value     any
	Values    []any
}

type In

type In struct {
	Value any
}

func NewIn

func NewIn(v any) In

func (In) GetValue

func (t In) GetValue() any

func (In) SetValue

func (t In) SetValue(v any)

type InOut

type InOut struct {
	Value any
}

func NewInOut

func NewInOut(v any) InOut

func (InOut) GetValue

func (t InOut) GetValue() *sql.Out

type Out

type Out struct {
	Value any
}

func NewOut

func NewOut(v any) Out

func (Out) GetValue

func (t Out) GetValue() *sql.Out

type Scanner added in v1.1.1

type Scanner interface {
	Scan(fieldname string, value any)

	// ToGdao
	// : when don't create an object by calling a New method of the standardized entity class,
	// but by using some other method such as the new keyword, then should call the ToGdao function,
	// which initializes the relevant data for database operations
	ToGdao()
}

type Serialize

type Serialize[T any] interface {
	Encode(T) ([]byte, error)
	Decode([]byte) (T, error)
}

type Serializer

type Serializer struct {
}

func (*Serializer) Decode

func (t *Serializer) Decode(data []byte) (map[string]interface{}, error)

func (*Serializer) Encode

func (t *Serializer) Encode(data map[string]interface{}) ([]byte, error)

type Sort

type Sort[T any] struct {
	OrderByArg string
}

type TableBase

type TableBase interface {
	TableName() string
}

type Transaction

type Transaction interface {
	DBhandle
	IsClose() bool
	Commit() error
	Rollback() error
}

type Where

type Where[T any] struct {
	WhereSql string
	Value    any
	Values   []any
}

func (*Where[T]) And

func (w *Where[T]) And(wheres ...*Where[T]) *Where[T]

func (*Where[T]) Or

func (w *Where[T]) Or(wheres ...*Where[T]) *Where[T]

Jump to

Keyboard shortcuts

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