Documentation ¶
Index ¶
- func CountSQL(sql string) string
- func CountTable(c sqlx.SqlConn, table string) (int64, error)
- func CreateDbIne(dsn string) error
- func CreateMysqlIndexes(conn sqlx.SqlConn, db, table string, indexes []string) error
- func GenerateSQLInsert(table string, data interface{}) string
- func GetLengthTag(field reflect.StructField) (int, error)
- func GetMysqlTableComment(source, table string) (string, error)
- func MysqlListTable(db *sql.DB) ([]string, error)
- func MysqlPing(dsn string) error
- func PageSQL(sql string, page, pageSize int) (string, int, int)
- func ParseMySQLDatabase(dsn string) (string, string, error)
- func TakeMySQLConn(dsn string) (*sql.DB, error)
- func TakeMySQLConnx(dsn string) sqlx.SqlConn
- func ToClickhouseTable(dsn, db, table, indexes string, withTime bool) ([]string, string, error)
- type Column
- type Count
- type MySQLModel
- func (m *MySQLModel) All() (interface{}, error)
- func (b *MySQLModel) BatchInsert(vs interface{}) error
- func (b *MySQLModel) Count(where string, args ...interface{}) (int64, error)
- func (b *MySQLModel) Delete(id interface{}) (int64, error)
- func (b *MySQLModel) DeleteWhere(where string, args ...interface{}) (int64, error)
- func (b *MySQLModel) Drop() error
- func (b *MySQLModel) DropIfExists() error
- func (b *MySQLModel) FindBy(field string, fieldValue interface{}) (interface{}, error)
- func (b *MySQLModel) FindWhere(where string, args ...interface{}) (interface{}, error)
- func (b *MySQLModel) Insert(data interface{}) (int64, error)
- func (m *MySQLModel) MustAll() interface{}
- func (b *MySQLModel) QueryWhere(where string, args ...interface{}) (interface{}, error)
- func (b *MySQLModel) Update(id interface{}, sets string, args ...interface{}) (int64, error)
- func (m *MySQLModel) UpdateWhere(sets, where string, args ...interface{}) (int64, error)
- type MysqlTableComment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDbIne ¶
func CreateMysqlIndexes ¶
func GenerateSQLInsert ¶
func GetLengthTag ¶
func GetLengthTag(field reflect.StructField) (int, error)
func GetMysqlTableComment ¶
func ParseMySQLDatabase ¶
ParseMySQLDatabase 会在连接串中加上时间类型和时区设置,返回修改后的dsn、数据库名称和error
func TakeMySQLConnx ¶
Types ¶
type Column ¶
type MySQLModel ¶
type MySQLModel struct { Conn sqlx.SqlConn AppName string Dsn string Database string TableName string Type reflect.Type Indexes []string DBs []string MutableFieldDBs []string // 字段的tag里面的db:"" MutableFieldNames []string // 字段的名字 // contains filtered or unexported fields }
func MustNewMySQLModel ¶
func MustNewMySQLModel(appName, dsn string, data interface{}) (*MySQLModel, bool, error)
MustNewMySQLModel 按照data结构体来建表,如果已存在则删掉他重新建
func NewMySQLModel ¶
func NewMySQLModel(appName, dsn string, data interface{}) (*MySQLModel, bool, error)
NewMySQLModel 新建基础Model,按照data结构体来建表,如果已存在则不建表,但是会检测每一列是否和结构体字段对得上
func (*MySQLModel) All ¶
func (m *MySQLModel) All() (interface{}, error)
func (*MySQLModel) BatchInsert ¶
func (b *MySQLModel) BatchInsert(vs interface{}) error
BatchInsert 批量插入
func (*MySQLModel) Count ¶
func (b *MySQLModel) Count(where string, args ...interface{}) (int64, error)
func (*MySQLModel) Delete ¶
func (b *MySQLModel) Delete(id interface{}) (int64, error)
func (*MySQLModel) DeleteWhere ¶
func (b *MySQLModel) DeleteWhere(where string, args ...interface{}) (int64, error)
func (*MySQLModel) DropIfExists ¶
func (b *MySQLModel) DropIfExists() error
func (*MySQLModel) FindBy ¶
func (b *MySQLModel) FindBy(field string, fieldValue interface{}) (interface{}, error)
func (*MySQLModel) FindWhere ¶
func (b *MySQLModel) FindWhere(where string, args ...interface{}) (interface{}, error)
func (*MySQLModel) Insert ¶
func (b *MySQLModel) Insert(data interface{}) (int64, error)
func (*MySQLModel) MustAll ¶
func (m *MySQLModel) MustAll() interface{}
func (*MySQLModel) QueryWhere ¶
func (b *MySQLModel) QueryWhere(where string, args ...interface{}) (interface{}, error)
QueryWhere 按条件查询
where : 查询条件,如果为空则没有查询条件。如:where="id=1" -> `select .. from table where id=1` . where="" -> `select .. from table`
返回:结构体的指针切片类型的interface{},如:[]*User类型
func (*MySQLModel) Update ¶
func (b *MySQLModel) Update(id interface{}, sets string, args ...interface{}) (int64, error)
func (*MySQLModel) UpdateWhere ¶
func (m *MySQLModel) UpdateWhere(sets, where string, args ...interface{}) (int64, error)
type MysqlTableComment ¶
type MysqlTableComment struct {
TableComment string `db:"TABLE_COMMENT"`
}
Click to show internal directories.
Click to hide internal directories.