Documentation
¶
Index ¶
- Variables
- func AnyToBool(v any) bool
- func AnyToFloat64(v any) (ret float64)
- func AnyToInt64(v any) (ret int64)
- func AnyToStr(v any) (ret string)
- func InArray(needle any, haystack any) bool
- func NumCPU() int
- func RandIntN(i int) int
- func RandRange(min, max int) int
- type MysqlClient
- func (c *MysqlClient) CloseDB()
- func (c *MysqlClient) Count(ctx context.Context, query string, params ...any) (cnt int64, err error)
- func (c *MysqlClient) Delete(ctx context.Context, query string, params ...any) (int64, error)
- func (c *MysqlClient) DeleteByIds(ctx context.Context, table string, ids ...any) (int64, error)
- func (c *MysqlClient) GetDB(ctx context.Context, useSlave bool) (*sql.DB, error)
- func (c *MysqlClient) Insert(ctx context.Context, table string, row *MysqlRow) (ret int64, err error)
- func (c *MysqlClient) InsertBatch(ctx context.Context, table string, rows []*MysqlRow) (ret int64, err error)
- func (c *MysqlClient) InsertDuplicate(ctx context.Context, table string, row *MysqlRow) (ret int64, err error)
- func (c *MysqlClient) InsertIgnore(ctx context.Context, table string, row *MysqlRow) (ret int64, err error)
- func (c *MysqlClient) InsertReplace(ctx context.Context, table string, row *MysqlRow) (ret int64, err error)
- func (c *MysqlClient) Select(ctx context.Context, query string, params ...any) (rows []*MysqlRow, err error)
- func (c *MysqlClient) SelectByIds(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) error
- func (c *MysqlClient) SelectPage(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) (totalRows, totalPages, currentPage int64, err error)
- func (c *MysqlClient) SelectWalk(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) error
- func (c *MysqlClient) ShowColumns(ctx context.Context, table string) (map[string]string, error)
- func (c *MysqlClient) Transaction(ctx context.Context, fn func(ctx context.Context, tx *sql.Tx) error, ...) error
- func (c *MysqlClient) Truncate(ctx context.Context, table string) error
- func (c *MysqlClient) Update(ctx context.Context, query string, params ...any) (ret int64, err error)
- func (c *MysqlClient) UpdateById(ctx context.Context, table string, row *MysqlRow, id any) (int64, error)
- type MysqlConnOption
- type MysqlRow
- func (row *MysqlRow) Drop(keys ...string)
- func (row *MysqlRow) DropAll()
- func (row *MysqlRow) Get(key string) any
- func (row *MysqlRow) Has(key string) bool
- func (row *MysqlRow) IsEmpty() bool
- func (row *MysqlRow) Set(key string, val any)
- func (row *MysqlRow) ToBool(key string) bool
- func (row *MysqlRow) ToInt64(key string) int64
- func (row *MysqlRow) ToMap(key string) map[string]any
- func (row *MysqlRow) ToNum(key string) float64
- func (row *MysqlRow) ToStr(key string) string
- func (row *MysqlRow) ToStrings(key string) []string
- type MysqlTable
- func (mt *MysqlTable) AllWalk(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) error
- func (mt *MysqlTable) Count(ctx context.Context, query string, params ...any) (cnt int64, err error)
- func (mt *MysqlTable) Delete(ctx context.Context, query string, params ...any) (int64, error)
- func (mt *MysqlTable) DeleteByIds(ctx context.Context, ids ...any) (int64, error)
- func (mt *MysqlTable) GetOne(ctx context.Context, id any) (*MysqlRow, error)
- func (mt *MysqlTable) IdsWalk(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) error
- func (mt *MysqlTable) Insert(ctx context.Context, row *MysqlRow) (int64, error)
- func (mt *MysqlTable) InsertBatch(ctx context.Context, rows []*MysqlRow) (int64, error)
- func (mt *MysqlTable) InsertDuplicate(ctx context.Context, row *MysqlRow) (int64, error)
- func (mt *MysqlTable) InsertIgnore(ctx context.Context, row *MysqlRow) (int64, error)
- func (mt *MysqlTable) InsertReplace(ctx context.Context, row *MysqlRow) (int64, error)
- func (mt *MysqlTable) Select(ctx context.Context, query string, params ...any) ([]*MysqlRow, error)
- func (mt *MysqlTable) SelectPage(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) (totalRows, totalPages, currentPage int64, err error)
- func (mt *MysqlTable) SelectWalk(ctx context.Context, fn func(ctx context.Context, row *MysqlRow) error, ...) error
- func (mt *MysqlTable) ShowColumns(ctx context.Context) (map[string]string, error)
- func (mt *MysqlTable) Transaction(ctx context.Context, fn func(ctx context.Context, tx *sql.Tx) error, ...) error
- func (mt *MysqlTable) Truncate(ctx context.Context) error
- func (mt *MysqlTable) Update(ctx context.Context, query string, params ...any) (int64, error)
- func (mt *MysqlTable) UpdateById(ctx context.Context, row *MysqlRow, id any) (int64, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AnyToFloat64 ¶
func AnyToInt64 ¶
Types ¶
type MysqlClient ¶
type MysqlClient struct { Listener func(ctx context.Context, query string, err error, args ...any) ConnOptions []*MysqlConnOption TimeoutInsert time.Duration TimeoutSelect time.Duration TimeoutUpdate time.Duration TimeoutTrans time.Duration // contains filtered or unexported fields }
func NewMysqlClient ¶
func NewMysqlClient(connOptions ...*MysqlConnOption) (*MysqlClient, error)
func NewMysqlClientEasy ¶
func NewMysqlClientEasy(dsn ...string) (*MysqlClient, error)
func (*MysqlClient) CloseDB ¶
func (c *MysqlClient) CloseDB()
func (*MysqlClient) DeleteByIds ¶
func (*MysqlClient) InsertBatch ¶
func (*MysqlClient) InsertDuplicate ¶
func (*MysqlClient) InsertIgnore ¶
func (*MysqlClient) InsertReplace ¶
func (*MysqlClient) SelectByIds ¶
func (*MysqlClient) SelectPage ¶
func (*MysqlClient) SelectWalk ¶
func (*MysqlClient) ShowColumns ¶
func (*MysqlClient) Transaction ¶
func (*MysqlClient) Truncate ¶
func (c *MysqlClient) Truncate(ctx context.Context, table string) error
func (*MysqlClient) UpdateById ¶
type MysqlConnOption ¶
type MysqlConnOption struct { Dsn string Addr string DbName string MaxOpen int MaxIdle int MaxIdleTime time.Duration MaxLifetime time.Duration }
func NewMysqlConnOption ¶
type MysqlRow ¶
func NewMysqlRow ¶
func NewMysqlRow() *MysqlRow
type MysqlTable ¶
type MysqlTable struct { Client *MysqlClient Name string }
func NewMysqlTable ¶
func NewMysqlTable(client *MysqlClient, name string) *MysqlTable
func (*MysqlTable) DeleteByIds ¶
func (*MysqlTable) InsertBatch ¶
func (*MysqlTable) InsertDuplicate ¶
func (*MysqlTable) InsertIgnore ¶
func (*MysqlTable) InsertReplace ¶
func (*MysqlTable) SelectPage ¶
func (*MysqlTable) SelectWalk ¶
func (*MysqlTable) ShowColumns ¶
func (*MysqlTable) Transaction ¶
func (*MysqlTable) UpdateById ¶
Click to show internal directories.
Click to hide internal directories.