Documentation ¶
Index ¶
- Constants
- func GetCacher(config configs.AllConfig, dbConfig configs.DbConfig) (cacher *xorm.LRUCacher, err error)
- func InitDb(config configs.AllConfig, dbConfig configs.DbConfig) (engine xorm.EngineInterface, err error)
- type Cond
- type Dao
- type Models
- type XormDao
- func (d *XormDao) Begin() error
- func (d *XormDao) ClearCache(t interface{})
- func (d *XormDao) Close()
- func (d *XormDao) Commit() error
- func (d *XormDao) Count(t interface{}, cond Cond) (total int64, err error)
- func (d *XormDao) DisableCache(t interface{})
- func (d *XormDao) EnableCache(t interface{})
- func (d *XormDao) Exec(sqlStr string, args ...interface{}) (rs sql.Result, err error)
- func (d *XormDao) GetMulti(t interface{}, ids ...interface{}) (err error)
- func (d *XormDao) Insert(t interface{}) (affected int64, err error)
- func (d *XormDao) InsertMulti(t interface{}) (affected int64, err error)
- func (d *XormDao) Iterate(t interface{}, cond Cond, f xorm.IterFunc) (err error)
- func (d *XormDao) NewSession()
- func (d *XormDao) Query(args ...interface{}) (rs []map[string][]byte, err error)
- func (d *XormDao) QueryInterface(args ...interface{}) (rs []map[string]interface{}, err error)
- func (d *XormDao) QueryString(args ...interface{}) (rs []map[string]string, err error)
- func (d *XormDao) Replace(sql string, cond Cond) (id int64, err error)
- func (d *XormDao) Rollback() error
- func (d *XormDao) Rows(t interface{}, cond Cond) (rows *xorm.Rows, err error)
- func (d *XormDao) Search(t interface{}, cond Cond) (err error)
- func (d *XormDao) SearchAndCount(t interface{}, cond Cond) (total int64, err error)
- func (d *XormDao) SearchOne(t interface{}, cond Cond) (has bool, err error)
- func (d *XormDao) UpdateById(t interface{}) (affected int64, err error)
- func (d *XormDao) UpdateByIds(t interface{}, params Cond, ids []interface{}) (affected int64, err error)
- func (d *XormDao) UpdateByWhere(t interface{}, params Cond, where Cond) (affected int64, err error)
Constants ¶
View Source
const DefaultPageSize = 1000
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dao ¶
type Dao interface { UpdateById(interface{}) (int64, error) UpdateByIds(interface{}, Cond, []interface{}) (int64, error) UpdateByWhere(interface{}, Cond, Cond) (int64, error) Insert(interface{}) (int64, error) SearchOne(interface{}, Cond) (bool, error) Search(interface{}, Cond) error GetMulti(interface{}, ...interface{}) error Count(interface{}, Cond) (int64, error) EnableCache(interface{}) DisableCache(interface{}) }
type Models ¶
type Models struct { Id int `json:"id" xorm:"not null pk autoincr INT(10)"` IsDeleted int `json:"is_deleted" xorm:"not null default 0 TINYINT(1)"` UpdatedAt time.Time `json:"updated_at" xorm:"not null default 'CURRENT_TIMESTAMP' TIMESTAMP updated"` CreatedAt time.Time `json:"created_at" xorm:"not null default 'CURRENT_TIMESTAMP' TIMESTAMP created"` }
func (*Models) GetCreatedAt ¶
func (*Models) GetIsDeleted ¶
func (*Models) GetUpdatedAt ¶
type XormDao ¶
type XormDao struct {
// contains filtered or unexported fields
}
func NewXormDao ¶
config用于缓存,dbConfig用于数据库配置
func (*XormDao) DisableCache ¶
func (d *XormDao) DisableCache(t interface{})
func (*XormDao) EnableCache ¶
func (d *XormDao) EnableCache(t interface{})
func (*XormDao) InsertMulti ¶
func (*XormDao) NewSession ¶
func (d *XormDao) NewSession()
以下主要用于事务 用法 首先NewSession,然后defer Close 然后Begin,如果不Commit,会自动在Close里Rollback掉 Notice: 注意并发不安全,请勿在全局上使用
func (*XormDao) QueryInterface ¶
func (*XormDao) QueryString ¶
func (*XormDao) SearchAndCount ¶
func (*XormDao) UpdateById ¶
func (*XormDao) UpdateByIds ¶
Click to show internal directories.
Click to hide internal directories.