mysql

package
v0.0.0-...-a2bc238 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldID         = Field("id")
	FieldUUID       = Field("uuid")
	FieldCreateTime = Field("create_time")
	FieldUpdateTime = Field("last_update_time")
	FieldName       = Field("name")
	FieldIsDeleted  = Field("is_deleted")
	FieldDeleteTime = Field("deleted_time")
	FieldUser       = Field("user")
	FieldType       = Field("typ")
)

Fields for mysql tables

Variables

This section is empty.

Functions

func DeleteRows

func DeleteRows(ctx context.Context, db *sqlx.DB, tx *sqlx.Tx, table string, whereClause []WhereClause, ops ...Option) (int64, error)

DeleteRows is a util function to delete rows from a table

func InsertRows

func InsertRows(ctx context.Context, db *sqlx.DB, tx *sqlx.Tx, table string, rowFields []Field, rowValues [][]Value, ops ...Option) (int64, error)

InsertRows is a util function to insert some rows into a table

func SelectRows

func SelectRows(ctx context.Context, db *sqlx.DB, tx *sqlx.Tx, table string, fields []Field, whereClause []WhereClause, result interface{}, ops ...Option) error

SelectRows is a util function to select some rows from a table

func TransactionHandler

func TransactionHandler(ctx context.Context, db *sqlx.DB, txFunc func(*sqlx.Tx) error) (err error)

TransactionHandler is a wrapper function for mysql transcations

func UpdateRows

func UpdateRows(ctx context.Context, db *sqlx.DB, tx *sqlx.Tx, table string, values map[Field]Value, whereClause []WhereClause) (int64, error)

UpdateRows is a util function to update rows values in a table

Types

type Client

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

Client for mysql db

func New

func New(addr string, ops ...Option) (*Client, error)

New will create a mysql-backend client

func (*Client) Close

func (cli *Client) Close() error

Close the db behind the mysql client

func (*Client) DB

func (cli *Client) DB() *sqlx.DB

DB handler of the client

type Field

type Field string

Field name of a row field

type Option

type Option func(opt *options)

Option for MySQL Client

func WithExtra

func WithExtra(extra string) Option

WithExtra set extra sql statements

func WithMaxConnsCount

func WithMaxConnsCount(count int) Option

WithMaxConnsCount set max conns count for MySQL Client

func WithMaxIdleConnsCount

func WithMaxIdleConnsCount(count int) Option

WithMaxIdleConnsCount set max idle conns count for MySQL Client

type Value

type Value interface{}

Value of a msyql column

type WhereClause

type WhereClause map[Field]Value

WhereClause for sql

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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