Documentation ¶
Index ¶
- Constants
- Variables
- func Close(params ...string) (err error)
- func Register(poolName, dsn string, params ...string) error
- func Using(params ...string) (*xorm.Session, error)
- type Model
- func (m *Model) AllCols() *Model
- func (m *Model) And(column string, args ...interface{}) *Model
- func (m *Model) Asc(colNames ...string) *Model
- func (m *Model) Cols(columns ...string) *Model
- func (m *Model) Count(bean ...interface{}) (int64, error)
- func (m *Model) Delete(bean interface{}) (int64, error)
- func (m *Model) Desc(colNames ...string) *Model
- func (m *Model) Distinct(columns ...string) *Model
- func (m *Model) Exist(bean ...interface{}) (bool, error)
- func (m *Model) FilterID(id interface{}) *Model
- func (m *Model) FindAll(rowsSlicePtr interface{}, condiBean ...interface{}) error
- func (m *Model) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
- func (m *Model) FindOne(bean interface{}) (bool, error)
- func (m *Model) GroupBy(keys string) *Model
- func (m *Model) Having(conditions string) *Model
- func (m *Model) IN(column string, args ...interface{}) *Model
- func (m *Model) LastSQL() (string, []interface{})
- func (m *Model) Limit(limit int, start ...int) *Model
- func (m *Model) NotIn(column string, args ...interface{}) *Model
- func (m *Model) Or(column string, args ...interface{}) *Model
- func (m *Model) OrderBy(order string) *Model
- func (m *Model) Pagination(page, pagesize int, data interface{}) (currentPage, currentPagesize, totalRecords, totalPages int, err error)
- func (m *Model) Rows(bean interface{}) (*xorm.Rows, error)
- func (m *Model) SQL(query interface{}, args ...interface{}) *Model
- func (m *Model) Save() (int64, error)
- func (m *Model) SessionInit(session *xorm.Session, tableNameOrBean interface{})
- func (m *Model) Update() (int64, error)
- func (m *Model) Where(query interface{}, args ...interface{}) *Model
- type XormSession
- type Xorms
Constants ¶
View Source
const ( SnakeMapper = "snake" SameMapper = "same" GonicMapper = "gonic" )
Variables ¶
View Source
var ConnMaxLifetimeDefault time.Duration = 30 * time.Second
View Source
var MaxIdleConnsDefault int = 16
View Source
var MaxOpenConnsDefault int = 32
Functions ¶
func Close ¶
Close 关闭连接 范例: Close() 关闭名字为default的连接 Close("my") 关闭名字为my的连接 Close("my","your") 关闭多个连接 Close("__all__") 关闭所有的连接。
func Register ¶ added in v1.1.0
Register 注册一个mysql连接池 范例:
给连接池取个名称 Register("default","test:test@(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=True&loc=Local") 指定表前缀 Register("default","test:test@(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=True&loc=Local","prefix_") 设置调试模式,会打印sql语句 Register("default","test:test@(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=True&loc=Local","prefix_","true") 指定xorm的mapper规则 Register("default","test:test@(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=True&loc=Local","prefix_","true","gonic)
Types ¶
type Model ¶ added in v1.1.0
type Model struct {
// contains filtered or unexported fields
}
func (*Model) FindAndCount ¶ added in v1.1.0
func (*Model) Pagination ¶ added in v1.1.1
func (*Model) SessionInit ¶ added in v1.1.0
type XormSession ¶
type XormSession struct { Name string DSN string Prefix string Mapper string ConnMaxLifetime time.Duration MaxIdleConns int MaxOpenConns int Debug bool // contains filtered or unexported fields }
func (*XormSession) Close ¶
func (xc *XormSession) Close() error
func (*XormSession) Connect ¶
func (xc *XormSession) Connect() (err error)
Click to show internal directories.
Click to hide internal directories.