Documentation ¶
Index ¶
- Constants
- Variables
- func BlindlyQuote(engine *xorm.Engine, sep string, words ...string) string
- func CalcPage(pageno, pagesize, total int) (int, int)
- func ClusterInsertMulti(xi xorm.Interface, objs []IResetTable, reset, trunc bool) (total int64, err error)
- func CreateTableLike(engine *xorm.Engine, curr, orig string) (bool, error)
- func FindTables(engine *xorm.Engine, prefix string, fullName bool) []string
- func GetPrimarykey(engine *xorm.Engine, m interface{}) *schemas.Column
- func JoinQuery(engine *xorm.Engine, query *xorm.Session, table, fkey string, ...) (*xorm.Session, []string)
- func MoveEdge(query *xorm.Session, table string, base, offset int) error
- func NegativeOffset(offset, pagesize, total int) int
- func Paginate(query *xorm.Session, pageno, pagesize int) *xorm.Session
- func Qprintf(engine *xorm.Engine, format string, args ...interface{}) string
- func RebuildNestedByDepth(query *xorm.Session, table string) error
- func SessListJoin(data []string) string
- func SessListSplit(data string) []string
- type ClusterMixin
- func GetClusterMixinFor(kind, prefix string, engine *xorm.Engine) *ClusterMixin
- func NewClusterDaily(t time.Time) *ClusterMixin
- func NewClusterHourly(t time.Time) *ClusterMixin
- func NewClusterMixin(kind string, t time.Time) *ClusterMixin
- func NewClusterMonthly(t time.Time) *ClusterMixin
- func NewClusterQuarterly(t time.Time) *ClusterMixin
- func NewClusterWeekly(t time.Time) *ClusterMixin
- type ClusterQuery
- func (q *ClusterQuery) AddFilter(filter FilterFunc) *ClusterQuery
- func (q *ClusterQuery) ClearFilters() *ClusterQuery
- func (q *ClusterQuery) ClusterCount(bean ...interface{}) (int64, error)
- func (q *ClusterQuery) ClusterPaginate(pageno, pagesize int, rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
- func (q *ClusterQuery) Count(bean ...interface{}) (int64, error)
- func (q *ClusterQuery) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
- func (q *ClusterQuery) GetQuery() *xorm.Session
- func (q *ClusterQuery) GetTable() string
- func (q *ClusterQuery) Limit(limit int, start ...int) *ClusterQuery
- func (q *ClusterQuery) OrderBy(order string) *ClusterQuery
- func (q ClusterQuery) Quote(value string) string
- type FilterFunc
- type ForeignTable
- type IResetTable
- type ITableComment
- type ITableName
- type LeftJoinQuery
- func (q *LeftJoinQuery) AddFilter(filter FilterFunc) *LeftJoinQuery
- func (q *LeftJoinQuery) AddLeftJoin(foreign ITableName, pkey, fkey, alias string) *LeftJoinQuery
- func (q *LeftJoinQuery) ClearFilters() *LeftJoinQuery
- func (q *LeftJoinQuery) Count(bean ...interface{}) (int64, error)
- func (q *LeftJoinQuery) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
- func (q *LeftJoinQuery) FindPaginate(pageno, pagesize int, rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
- func (q *LeftJoinQuery) GetQuery() *xorm.Session
- func (q *LeftJoinQuery) LeftJoin(foreign ITableName, fkey string) *LeftJoinQuery
- func (q *LeftJoinQuery) Limit(limit int, start ...int) *LeftJoinQuery
- func (q *LeftJoinQuery) OrderBy(order string) *LeftJoinQuery
- func (q LeftJoinQuery) Quote(value string) string
- type ModifyFunc
- type NestedMixin
- type NestedRow
- type Session
- func (sess *Session) AddFlash(messages ...string) (int, error)
- func (sess *Session) BindRoles(uid string, roles []string, kick bool) (string, error)
- func (sess *Session) GetFlashes(n int) ([]string, error)
- func (sess *Session) GetKey() string
- func (sess *Session) WrapExec(cmd string, args ...interface{}) (interface{}, error)
- type SessionRegistry
- type TimeMixin
Constants ¶
View Source
const ( SESS_FOR_EVER = -1 // 无限 SESS_NOT_EXISTS = -2 // 不存在 SESS_ERR_REDIS = -3 // redis错误 SESS_PREFIX = "sess" // 会话缓存前缀 SESS_LIST_SEP = ";" // 角色名之间的分隔符 SESS_TOKEN_KEY = "_token_" SESS_ONLINE_KEY = "onlines" // 在线用户 MAX_TIMEOUT = 86400 * 30 // 接近无限时间 )
Variables ¶
View Source
var NESTED_EDGE_OFFSET = 2
Functions ¶
func BlindlyQuote ¶
盲转义,认定字段名以小写字母开头
func ClusterInsertMulti ¶ added in v0.9.8
func ClusterInsertMulti(xi xorm.Interface, objs []IResetTable, reset, trunc bool) (total int64, err error)
*
- 写入多行到分布式表中
func CreateTableLike ¶ added in v0.9.8
复制表结构,只用于MySQL
func FindTables ¶ added in v0.9.8
找出符合前缀的表名
func GetPrimarykey ¶
获取Model的字段列表
func JoinQuery ¶
func JoinQuery(engine *xorm.Engine, query *xorm.Session, table, fkey string, foreign ForeignTable) (*xorm.Session, []string)
联表查询
func RebuildNestedByDepth ¶ added in v1.0.1
按照深度重建,即用之前比它深度小且最近的一个作为父节点
func SessListJoin ¶
func SessListSplit ¶
Types ¶
type ClusterMixin ¶ added in v0.9.8
type ClusterMixin struct { Date time.Time Suffixes sort.StringSlice TableNamePrefix string Kind, Format string }
按月分表
func GetClusterMixinFor ¶ added in v0.9.8
func GetClusterMixinFor(kind, prefix string, engine *xorm.Engine) *ClusterMixin
func NewClusterDaily ¶ added in v0.9.8
func NewClusterDaily(t time.Time) *ClusterMixin
func NewClusterHourly ¶ added in v0.9.8
func NewClusterHourly(t time.Time) *ClusterMixin
func NewClusterMixin ¶ added in v0.9.8
func NewClusterMixin(kind string, t time.Time) *ClusterMixin
func NewClusterMonthly ¶ added in v0.9.8
func NewClusterMonthly(t time.Time) *ClusterMixin
func NewClusterQuarterly ¶ added in v0.9.8
func NewClusterQuarterly(t time.Time) *ClusterMixin
func NewClusterWeekly ¶ added in v0.9.8
func NewClusterWeekly(t time.Time) *ClusterMixin
func (ClusterMixin) GetSuffix ¶ added in v0.9.8
func (m ClusterMixin) GetSuffix() string
func (*ClusterMixin) Move ¶ added in v0.9.8
func (m *ClusterMixin) Move(n int) *ClusterMixin
func (*ClusterMixin) Next ¶ added in v0.9.8
func (m *ClusterMixin) Next() bool
func (*ClusterMixin) Prev ¶ added in v0.9.8
func (m *ClusterMixin) Prev() bool
func (*ClusterMixin) SetTime ¶ added in v0.9.8
func (m *ClusterMixin) SetTime(t time.Time, toFirst bool) *ClusterMixin
type ClusterQuery ¶ added in v0.9.8
type ClusterQuery struct { *ClusterMixin *xorm.Session // contains filtered or unexported fields }
分布式查询
func NewClusterQuery ¶ added in v0.9.8
func NewClusterQuery(engine *xorm.Engine, cluster *ClusterMixin) *ClusterQuery
func (*ClusterQuery) AddFilter ¶ added in v0.9.8
func (q *ClusterQuery) AddFilter(filter FilterFunc) *ClusterQuery
func (*ClusterQuery) ClearFilters ¶ added in v0.9.8
func (q *ClusterQuery) ClearFilters() *ClusterQuery
func (*ClusterQuery) ClusterCount ¶ added in v0.9.8
func (q *ClusterQuery) ClusterCount(bean ...interface{}) (int64, error)
分布式计数,查询全部表
func (*ClusterQuery) ClusterPaginate ¶ added in v0.9.8
func (q *ClusterQuery) ClusterPaginate(pageno, pagesize int, rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
分布式计数和翻页,查询全部表,但只获取部分结果集
func (*ClusterQuery) Count ¶ added in v0.9.8
func (q *ClusterQuery) Count(bean ...interface{}) (int64, error)
计数,只查询当前表
func (*ClusterQuery) FindAndCount ¶ added in v0.9.8
func (q *ClusterQuery) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
计数和获取结果集,只查询当前表
func (*ClusterQuery) GetQuery ¶ added in v0.9.8
func (q *ClusterQuery) GetQuery() *xorm.Session
重新构建当前查询,因为每次 COUNT 和 FIND 等操作会释放查询(只有主表名还保留着)
func (*ClusterQuery) Limit ¶ added in v0.9.8
func (q *ClusterQuery) Limit(limit int, start ...int) *ClusterQuery
func (*ClusterQuery) OrderBy ¶ added in v0.9.8
func (q *ClusterQuery) OrderBy(order string) *ClusterQuery
func (ClusterQuery) Quote ¶ added in v0.9.8
func (q ClusterQuery) Quote(value string) string
type ForeignTable ¶
type ForeignTable struct { Join join.JoinOp Table ITableName Alias string Index string }
关联表
type IResetTable ¶ added in v0.9.8
type IResetTable interface { ResetTable(curr string, trunc bool) error ITableName }
*
- 创建或清空表
type LeftJoinQuery ¶
type LeftJoinQuery struct { Native ITableName ForeignKeys []string Foreigns map[string]ForeignTable *xorm.Session // contains filtered or unexported fields }
Left Join 联表查询
func NewLeftJoinQuery ¶
func NewLeftJoinQuery(engine *xorm.Engine, native ITableName) *LeftJoinQuery
native 为最左侧的主表,查询其所有字段
func (*LeftJoinQuery) AddFilter ¶
func (q *LeftJoinQuery) AddFilter(filter FilterFunc) *LeftJoinQuery
func (*LeftJoinQuery) AddLeftJoin ¶
func (q *LeftJoinQuery) AddLeftJoin(foreign ITableName, pkey, fkey, alias string) *LeftJoinQuery
添加次序要和 struct 定义一致
func (*LeftJoinQuery) ClearFilters ¶
func (q *LeftJoinQuery) ClearFilters() *LeftJoinQuery
func (*LeftJoinQuery) Count ¶
func (q *LeftJoinQuery) Count(bean ...interface{}) (int64, error)
计数,由于左联接数量只跟主表有关,这里不去 JOIN
func (*LeftJoinQuery) FindAndCount ¶
func (q *LeftJoinQuery) FindAndCount( rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
计数和获取结果集
func (*LeftJoinQuery) FindPaginate ¶ added in v0.9.8
func (q *LeftJoinQuery) FindPaginate(pageno, pagesize int, rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error)
计数和翻页,只获取部分结果集
func (*LeftJoinQuery) GetQuery ¶
func (q *LeftJoinQuery) GetQuery() *xorm.Session
重新构建当前查询,因为每次 COUNT 和 FIND 等操作会释放查询(只有主表名还保留着)
func (*LeftJoinQuery) LeftJoin ¶
func (q *LeftJoinQuery) LeftJoin(foreign ITableName, fkey string) *LeftJoinQuery
foreign 为副表,只查询其部分字段,读取字段的 json tag 作为字段名
func (*LeftJoinQuery) Limit ¶
func (q *LeftJoinQuery) Limit(limit int, start ...int) *LeftJoinQuery
func (*LeftJoinQuery) OrderBy ¶
func (q *LeftJoinQuery) OrderBy(order string) *LeftJoinQuery
func (LeftJoinQuery) Quote ¶
func (q LeftJoinQuery) Quote(value string) string
type NestedMixin ¶
type NestedMixin struct { Lft int `json:"lft" xorm:"notnull default 0 comment('左边界') INT(10)"` // 左边界 Rgt int `json:"rgt" xorm:"notnull default 0 comment('右边界') index INT(10)"` // 右边界 Depth int `json:"depth" xorm:"notnull default 1 comment('高度') index TINYINT(3)"` // 高度 }
嵌套集合树
func (*NestedMixin) AddToParent ¶
func (n *NestedMixin) AddToParent(parent *NestedMixin, query *xorm.Session, table string) (err error)
添加到父节点最末
func (NestedMixin) AncestorsFilter ¶
func (n NestedMixin) AncestorsFilter(backward bool) FilterFunc
找出所有直系祖先节点
func (NestedMixin) ChildrenFilter ¶
func (n NestedMixin) ChildrenFilter(rank int) FilterFunc
找出所有子孙节点
type NestedRow ¶ added in v1.0.1
type NestedRow struct { Id int `json:"id" xorm:"notnull pk autoincr INT(10)"` ParentIdNihility996 int `json:"-" xorm:"-"` // 阻止对象被混入其他 Model 的特殊字段 *NestedMixin `json:",inline" xorm:"extends"` }
type Session ¶
func NewSession ¶
func NewSession(reg *SessionRegistry, key string, timeout int) *Session
func (*Session) GetFlashes ¶
数量n为最大取出多少条消息,-1表示所有消息
type SessionRegistry ¶
type SessionRegistry struct { Onlines *redisw.RedisHash *redisw.RedisWrapper // contains filtered or unexported fields }
func NewRegistry ¶
func NewRegistry(w *redisw.RedisWrapper) *SessionRegistry
func (*SessionRegistry) DelSession ¶
func (sr *SessionRegistry) DelSession(token string) bool
func (SessionRegistry) GetKey ¶
func (sr SessionRegistry) GetKey(token string) string
func (*SessionRegistry) GetSession ¶
func (sr *SessionRegistry) GetSession(token string, timeout int) *Session
type TimeMixin ¶
type TimeMixin struct { CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"` // 创建时间 UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"` // 更新时间 DeletedAt time.Time `json:"deleted_at" xorm:"deleted comment('删除时间') index TIMESTAMP"` // 删除时间 }
*
- 时间相关的三个典型字段
Click to show internal directories.
Click to hide internal directories.