Documentation
¶
Index ¶
- Constants
- func CreateIndexes(conn *SqlConn, db, table string, indexes []string) error
- func CreateTableIfNotExists(conn *SqlConn, table, sql string) (bool, error)
- func GetDBTag(field reflect.StructField) string
- func GetDBTagMap(t reflect.Type) map[string]int
- func GetLengthTag(field reflect.StructField) (int, error)
- func GoTypeToSQLType(t reflect.Type, db string, length int) (string, bool, error)
- func ParseMySQLDatabase(dsn string) (string, string, error)
- func TableExists(conn *SqlConn, table string) (bool, error)
- type BaseMySQLModel
- func (b *BaseMySQLModel) Count(where string, args ...interface{}) (int64, error)
- func (b *BaseMySQLModel) Delete(id interface{}) (int64, error)
- func (b *BaseMySQLModel) FindBy(field string, fieldValue interface{}) (interface{}, error)
- func (b *BaseMySQLModel) Insert(data interface{}) error
- func (b *BaseMySQLModel) Update(id interface{}, sets string) (int64, error)
- type Column
- type Count
- type SqlConn
- func (s *SqlConn) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *SqlConn) QueryRow(v interface{}, query string, args ...interface{}) error
- func (s *SqlConn) QueryRowPartial(v interface{}, query string, args ...interface{}) error
- func (s *SqlConn) QueryRows(vs interface{}, query string, args ...interface{}) error
- func (s *SqlConn) QueryRowsPartial(vs interface{}, query string, args ...interface{}) error
Constants ¶
View Source
const LayoutTime = "2006-01-02 15:04:05"
Variables ¶
This section is empty.
Functions ¶
func CreateTableIfNotExists ¶
func GetDBTag ¶
func GetDBTag(field reflect.StructField) string
func GetLengthTag ¶
func GetLengthTag(field reflect.StructField) (int, error)
func GoTypeToSQLType ¶
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
Click to show internal directories.
Click to hide internal directories.