mysqlx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 10 Imported by: 0

README

mysqlx

MySQL driver extension for Golang

Documentation

Index

Constants

View Source
const LayoutTime = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func CreateIndexes

func CreateIndexes(conn *SqlConn, db, table string, indexes []string) error

func CreateTableIfNotExists

func CreateTableIfNotExists(conn *SqlConn, table, sql string) (bool, error)

func GetDBTag

func GetDBTag(field reflect.StructField) string

func GetDBTagMap

func GetDBTagMap(t reflect.Type) map[string]int

func GetLengthTag

func GetLengthTag(field reflect.StructField) (int, error)

func GoTypeToSQLType

func GoTypeToSQLType(t reflect.Type, db string, length int) (string, bool, error)

func ParseMySQLDatabase

func ParseMySQLDatabase(dsn string) (string, string, error)

func TableExists

func TableExists(conn *SqlConn, table string) (bool, error)

Types

type BaseMySQLModel

type BaseMySQLModel struct {
	Conn      *SqlConn
	AppName   string
	Database  string
	TableName string
	Type      reflect.Type

	Columns          []string
	ModifiableDBs    []string
	ModifiableFields []string
	// contains filtered or unexported fields
}

func NewBaseMySQLModel

func NewBaseMySQLModel(appName string, dsn string, data interface{}) (*BaseMySQLModel, bool, error)

NewBaseMySQLModel 新建基础Model

func (*BaseMySQLModel) Count

func (b *BaseMySQLModel) Count(where string, args ...interface{}) (int64, error)

func (*BaseMySQLModel) Delete

func (b *BaseMySQLModel) Delete(id interface{}) (int64, error)

func (*BaseMySQLModel) FindBy

func (b *BaseMySQLModel) FindBy(field string, fieldValue interface{}) (interface{}, error)

func (*BaseMySQLModel) Insert

func (b *BaseMySQLModel) Insert(data interface{}) error

func (*BaseMySQLModel) Update

func (b *BaseMySQLModel) Update(id interface{}, sets string) (int64, error)

type Column

type Column struct {
	Field string `db:"Field"`
}

func DescribeTable

func DescribeTable(conn *SqlConn, table string) ([]*Column, error)

type Count

type Count struct {
	Count int64 `db:"count"`
}

type SqlConn

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

func NewMySQL

func NewMySQL(dsn string) (*SqlConn, error)

func (*SqlConn) Exec

func (s *SqlConn) Exec(query string, args ...interface{}) (sql.Result, error)

func (*SqlConn) QueryRow

func (s *SqlConn) QueryRow(v interface{}, query string, args ...interface{}) error

func (*SqlConn) QueryRowPartial

func (s *SqlConn) QueryRowPartial(v interface{}, query string, args ...interface{}) error

func (*SqlConn) QueryRows

func (s *SqlConn) QueryRows(vs interface{}, query string, args ...interface{}) error

func (*SqlConn) QueryRowsPartial

func (s *SqlConn) QueryRowsPartial(vs interface{}, query string, args ...interface{}) error

Jump to

Keyboard shortcuts

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