Documentation ¶
Index ¶
- Variables
- type ContestantDao
- func (d *ContestantDao) All(where ...interface{}) ([]*model.Contestant, error)
- func (d *ContestantDao) And(where interface{}, args ...interface{}) *ContestantDao
- func (d *ContestantDao) Args(args ...interface{}) *ContestantDao
- func (d *ContestantDao) As(as string) *ContestantDao
- func (d *ContestantDao) Batch(batch int) *ContestantDao
- func (d *ContestantDao) Cache(duration time.Duration, name ...string) *ContestantDao
- func (d *ContestantDao) Chunk(limit int, callback func(entities []*model.Contestant, err error) bool)
- func (d *ContestantDao) Ctx(ctx context.Context) *ContestantDao
- func (d *ContestantDao) Data(data ...interface{}) *ContestantDao
- func (d *ContestantDao) Fields(fieldNamesOrMapStruct ...interface{}) *ContestantDao
- func (d *ContestantDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ContestantDao
- func (d *ContestantDao) Filter() *ContestantDao
- func (d *ContestantDao) FindAll(where ...interface{}) ([]*model.Contestant, error)
- func (d *ContestantDao) FindOne(where ...interface{}) (*model.Contestant, error)
- func (d *ContestantDao) Group(groupBy string) *ContestantDao
- func (d *ContestantDao) InnerJoin(table ...string) *ContestantDao
- func (d *ContestantDao) LeftJoin(table ...string) *ContestantDao
- func (d *ContestantDao) Limit(limit ...int) *ContestantDao
- func (d *ContestantDao) LockShared() *ContestantDao
- func (d *ContestantDao) LockUpdate() *ContestantDao
- func (d *ContestantDao) Master() *ContestantDao
- func (d *ContestantDao) Offset(offset int) *ContestantDao
- func (d *ContestantDao) OmitEmpty() *ContestantDao
- func (d *ContestantDao) One(where ...interface{}) (*model.Contestant, error)
- func (d *ContestantDao) Option(option int) *ContestantDao
- func (d *ContestantDao) Or(where interface{}, args ...interface{}) *ContestantDao
- func (d *ContestantDao) Order(orderBy ...string) *ContestantDao
- func (d *ContestantDao) Page(page, limit int) *ContestantDao
- func (d *ContestantDao) RightJoin(table ...string) *ContestantDao
- func (d *ContestantDao) Scan(pointer interface{}, where ...interface{}) error
- func (d *ContestantDao) Slave() *ContestantDao
- func (d *ContestantDao) Struct(pointer interface{}, where ...interface{}) error
- func (d *ContestantDao) Structs(pointer interface{}, where ...interface{}) error
- func (d *ContestantDao) TX(tx *gdb.TX) *ContestantDao
- func (d *ContestantDao) Unscoped() *ContestantDao
- func (d *ContestantDao) Where(where interface{}, args ...interface{}) *ContestantDao
- func (d *ContestantDao) WherePri(where interface{}, args ...interface{}) *ContestantDao
- type MatchDao
- func (d *MatchDao) All(where ...interface{}) ([]*model.Match, error)
- func (d *MatchDao) And(where interface{}, args ...interface{}) *MatchDao
- func (d *MatchDao) Args(args ...interface{}) *MatchDao
- func (d *MatchDao) As(as string) *MatchDao
- func (d *MatchDao) Batch(batch int) *MatchDao
- func (d *MatchDao) Cache(duration time.Duration, name ...string) *MatchDao
- func (d *MatchDao) Chunk(limit int, callback func(entities []*model.Match, err error) bool)
- func (d *MatchDao) Ctx(ctx context.Context) *MatchDao
- func (d *MatchDao) Data(data ...interface{}) *MatchDao
- func (d *MatchDao) Fields(fieldNamesOrMapStruct ...interface{}) *MatchDao
- func (d *MatchDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *MatchDao
- func (d *MatchDao) Filter() *MatchDao
- func (d *MatchDao) FindAll(where ...interface{}) ([]*model.Match, error)
- func (d *MatchDao) FindOne(where ...interface{}) (*model.Match, error)
- func (d *MatchDao) Group(groupBy string) *MatchDao
- func (d *MatchDao) InnerJoin(table ...string) *MatchDao
- func (d *MatchDao) LeftJoin(table ...string) *MatchDao
- func (d *MatchDao) Limit(limit ...int) *MatchDao
- func (d *MatchDao) LockShared() *MatchDao
- func (d *MatchDao) LockUpdate() *MatchDao
- func (d *MatchDao) Master() *MatchDao
- func (d *MatchDao) Offset(offset int) *MatchDao
- func (d *MatchDao) OmitEmpty() *MatchDao
- func (d *MatchDao) One(where ...interface{}) (*model.Match, error)
- func (d *MatchDao) Option(option int) *MatchDao
- func (d *MatchDao) Or(where interface{}, args ...interface{}) *MatchDao
- func (d *MatchDao) Order(orderBy ...string) *MatchDao
- func (d *MatchDao) Page(page, limit int) *MatchDao
- func (d *MatchDao) RightJoin(table ...string) *MatchDao
- func (d *MatchDao) Scan(pointer interface{}, where ...interface{}) error
- func (d *MatchDao) Slave() *MatchDao
- func (d *MatchDao) Struct(pointer interface{}, where ...interface{}) error
- func (d *MatchDao) Structs(pointer interface{}, where ...interface{}) error
- func (d *MatchDao) TX(tx *gdb.TX) *MatchDao
- func (d *MatchDao) Unscoped() *MatchDao
- func (d *MatchDao) Where(where interface{}, args ...interface{}) *MatchDao
- func (d *MatchDao) WherePri(where interface{}, args ...interface{}) *MatchDao
- type RuleDao
- func (d *RuleDao) All(where ...interface{}) ([]*model.Rule, error)
- func (d *RuleDao) And(where interface{}, args ...interface{}) *RuleDao
- func (d *RuleDao) Args(args ...interface{}) *RuleDao
- func (d *RuleDao) As(as string) *RuleDao
- func (d *RuleDao) Batch(batch int) *RuleDao
- func (d *RuleDao) Cache(duration time.Duration, name ...string) *RuleDao
- func (d *RuleDao) Chunk(limit int, callback func(entities []*model.Rule, err error) bool)
- func (d *RuleDao) Ctx(ctx context.Context) *RuleDao
- func (d *RuleDao) Data(data ...interface{}) *RuleDao
- func (d *RuleDao) Fields(fieldNamesOrMapStruct ...interface{}) *RuleDao
- func (d *RuleDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *RuleDao
- func (d *RuleDao) Filter() *RuleDao
- func (d *RuleDao) FindAll(where ...interface{}) ([]*model.Rule, error)
- func (d *RuleDao) FindOne(where ...interface{}) (*model.Rule, error)
- func (d *RuleDao) Group(groupBy string) *RuleDao
- func (d *RuleDao) InnerJoin(table ...string) *RuleDao
- func (d *RuleDao) LeftJoin(table ...string) *RuleDao
- func (d *RuleDao) Limit(limit ...int) *RuleDao
- func (d *RuleDao) LockShared() *RuleDao
- func (d *RuleDao) LockUpdate() *RuleDao
- func (d *RuleDao) Master() *RuleDao
- func (d *RuleDao) Offset(offset int) *RuleDao
- func (d *RuleDao) OmitEmpty() *RuleDao
- func (d *RuleDao) One(where ...interface{}) (*model.Rule, error)
- func (d *RuleDao) Option(option int) *RuleDao
- func (d *RuleDao) Or(where interface{}, args ...interface{}) *RuleDao
- func (d *RuleDao) Order(orderBy ...string) *RuleDao
- func (d *RuleDao) Page(page, limit int) *RuleDao
- func (d *RuleDao) RightJoin(table ...string) *RuleDao
- func (d *RuleDao) Scan(pointer interface{}, where ...interface{}) error
- func (d *RuleDao) Slave() *RuleDao
- func (d *RuleDao) Struct(pointer interface{}, where ...interface{}) error
- func (d *RuleDao) Structs(pointer interface{}, where ...interface{}) error
- func (d *RuleDao) TX(tx *gdb.TX) *RuleDao
- func (d *RuleDao) Unscoped() *RuleDao
- func (d *RuleDao) Where(where interface{}, args ...interface{}) *RuleDao
- func (d *RuleDao) WherePri(where interface{}, args ...interface{}) *RuleDao
- type ScoreDao
- func (d *ScoreDao) All(where ...interface{}) ([]*model.Score, error)
- func (d *ScoreDao) And(where interface{}, args ...interface{}) *ScoreDao
- func (d *ScoreDao) Args(args ...interface{}) *ScoreDao
- func (d *ScoreDao) As(as string) *ScoreDao
- func (d *ScoreDao) Batch(batch int) *ScoreDao
- func (d *ScoreDao) Cache(duration time.Duration, name ...string) *ScoreDao
- func (d *ScoreDao) Chunk(limit int, callback func(entities []*model.Score, err error) bool)
- func (d *ScoreDao) Ctx(ctx context.Context) *ScoreDao
- func (d *ScoreDao) Data(data ...interface{}) *ScoreDao
- func (d *ScoreDao) Fields(fieldNamesOrMapStruct ...interface{}) *ScoreDao
- func (d *ScoreDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ScoreDao
- func (d *ScoreDao) Filter() *ScoreDao
- func (d *ScoreDao) FindAll(where ...interface{}) ([]*model.Score, error)
- func (d *ScoreDao) FindOne(where ...interface{}) (*model.Score, error)
- func (d *ScoreDao) Group(groupBy string) *ScoreDao
- func (d *ScoreDao) InnerJoin(table ...string) *ScoreDao
- func (d *ScoreDao) LeftJoin(table ...string) *ScoreDao
- func (d *ScoreDao) Limit(limit ...int) *ScoreDao
- func (d *ScoreDao) LockShared() *ScoreDao
- func (d *ScoreDao) LockUpdate() *ScoreDao
- func (d *ScoreDao) Master() *ScoreDao
- func (d *ScoreDao) Offset(offset int) *ScoreDao
- func (d *ScoreDao) OmitEmpty() *ScoreDao
- func (d *ScoreDao) One(where ...interface{}) (*model.Score, error)
- func (d *ScoreDao) Option(option int) *ScoreDao
- func (d *ScoreDao) Or(where interface{}, args ...interface{}) *ScoreDao
- func (d *ScoreDao) Order(orderBy ...string) *ScoreDao
- func (d *ScoreDao) Page(page, limit int) *ScoreDao
- func (d *ScoreDao) RightJoin(table ...string) *ScoreDao
- func (d *ScoreDao) Scan(pointer interface{}, where ...interface{}) error
- func (d *ScoreDao) Slave() *ScoreDao
- func (d *ScoreDao) Struct(pointer interface{}, where ...interface{}) error
- func (d *ScoreDao) Structs(pointer interface{}, where ...interface{}) error
- func (d *ScoreDao) TX(tx *gdb.TX) *ScoreDao
- func (d *ScoreDao) Unscoped() *ScoreDao
- func (d *ScoreDao) Where(where interface{}, args ...interface{}) *ScoreDao
- func (d *ScoreDao) WherePri(where interface{}, args ...interface{}) *ScoreDao
- type UserDao
- func (d *UserDao) All(where ...interface{}) ([]*model.User, error)
- func (d *UserDao) And(where interface{}, args ...interface{}) *UserDao
- func (d *UserDao) Args(args ...interface{}) *UserDao
- func (d *UserDao) As(as string) *UserDao
- func (d *UserDao) Batch(batch int) *UserDao
- func (d *UserDao) Cache(duration time.Duration, name ...string) *UserDao
- func (d *UserDao) Chunk(limit int, callback func(entities []*model.User, err error) bool)
- func (d *UserDao) Ctx(ctx context.Context) *UserDao
- func (d *UserDao) Data(data ...interface{}) *UserDao
- func (d *UserDao) Fields(fieldNamesOrMapStruct ...interface{}) *UserDao
- func (d *UserDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *UserDao
- func (d *UserDao) Filter() *UserDao
- func (d *UserDao) FindAll(where ...interface{}) ([]*model.User, error)
- func (d *UserDao) FindOne(where ...interface{}) (*model.User, error)
- func (d *UserDao) Group(groupBy string) *UserDao
- func (d *UserDao) InnerJoin(table ...string) *UserDao
- func (d *UserDao) LeftJoin(table ...string) *UserDao
- func (d *UserDao) Limit(limit ...int) *UserDao
- func (d *UserDao) LockShared() *UserDao
- func (d *UserDao) LockUpdate() *UserDao
- func (d *UserDao) Master() *UserDao
- func (d *UserDao) Offset(offset int) *UserDao
- func (d *UserDao) OmitEmpty() *UserDao
- func (d *UserDao) One(where ...interface{}) (*model.User, error)
- func (d *UserDao) Option(option int) *UserDao
- func (d *UserDao) Or(where interface{}, args ...interface{}) *UserDao
- func (d *UserDao) Order(orderBy ...string) *UserDao
- func (d *UserDao) Page(page, limit int) *UserDao
- func (d *UserDao) RightJoin(table ...string) *UserDao
- func (d *UserDao) Scan(pointer interface{}, where ...interface{}) error
- func (d *UserDao) Slave() *UserDao
- func (d *UserDao) Struct(pointer interface{}, where ...interface{}) error
- func (d *UserDao) Structs(pointer interface{}, where ...interface{}) error
- func (d *UserDao) TX(tx *gdb.TX) *UserDao
- func (d *UserDao) Unscoped() *UserDao
- func (d *UserDao) Where(where interface{}, args ...interface{}) *UserDao
- func (d *UserDao) WherePri(where interface{}, args ...interface{}) *UserDao
Constants ¶
This section is empty.
Variables ¶
var ( // Contestant is globally public accessible object for table contestant operations. Contestant = ContestantDao{ M: g.DB("default").Model("contestant").Safe(), DB: g.DB("default"), Table: "contestant", Columns: contestantColumns{ Id: "id", Tid: "tid", Name: "name", Vurl: "vurl", Sid: "sid", Score: "score", CreatedAt: "created_at", UpdatedAt: "updated_at", }, } )
var ( // Match is globally public accessible object for table match operations. Match = MatchDao{ M: g.DB("default").Model("match").Safe(), DB: g.DB("default"), Table: "match", Columns: matchColumns{ Id: "id", Kvurl: "kvurl", Title: "title", Index: "index", Type: "type", CreatedAt: "created_at", UpdatedAt: "updated_at", }, } )
var ( // Rule is globally public accessible object for table rule operations. Rule = RuleDao{ M: g.DB("default").Model("rule").Safe(), DB: g.DB("default"), Table: "rule", Columns: ruleColumns{ Id: "id", Title: "title", Rules: "rules", Desc: "desc", Imgurl: "imgurl", CreatedAt: "created_at", UpdatedAt: "updated_at", }, } )
var ( // Score is globally public accessible object for table score operations. Score = ScoreDao{ M: g.DB("default").Model("score").Safe(), DB: g.DB("default"), Table: "score", Columns: scoreColumns{ Uid: "uid", Cid: "cid", Rules: "rules", Score: "score", Comments: "comments", CreatedAt: "created_at", UpdatedAt: "updated_at", }, } )
var ( // User is globally public accessible object for table user operations. User = UserDao{ M: g.DB("default").Model("user").Safe(), DB: g.DB("default"), Table: "user", Columns: userColumns{ Id: "id", Name: "name", Password: "password", Desc: "desc", Tid: "tid", Type: "type", Starttime: "starttime", Endtime: "endtime", CreatedAt: "created_at", UpdatedAt: "updated_at", }, } )
Functions ¶
This section is empty.
Types ¶
type ContestantDao ¶
ContestantDao is the manager for logic model data accessing and custom defined data operations functions management.
func (*ContestantDao) All ¶
func (d *ContestantDao) All(where ...interface{}) ([]*model.Contestant, error)
All does "SELECT FROM ..." statement for the model. It retrieves the records from table and returns the result as []*model.Contestant. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*ContestantDao) And ¶
func (d *ContestantDao) And(where interface{}, args ...interface{}) *ContestantDao
And adds "AND" condition to the where statement.
func (*ContestantDao) Args ¶
func (d *ContestantDao) Args(args ...interface{}) *ContestantDao
Args sets custom arguments for model operation.
func (*ContestantDao) As ¶
func (d *ContestantDao) As(as string) *ContestantDao
As sets an alias name for current table.
func (*ContestantDao) Batch ¶
func (d *ContestantDao) Batch(batch int) *ContestantDao
Batch sets the batch operation number for the model.
func (*ContestantDao) Cache ¶
func (d *ContestantDao) Cache(duration time.Duration, name ...string) *ContestantDao
Cache sets the cache feature for the model. It caches the result of the sql, which means if there's another same sql request, it just reads and returns the result from cache, it but not committed and executed into the database.
If the parameter <duration> < 0, which means it clear the cache with given <name>. If the parameter <duration> = 0, which means it never expires. If the parameter <duration> > 0, which means it expires after <duration>.
The optional parameter <name> is used to bind a name to the cache, which means you can later control the cache like changing the <duration> or clearing the cache with specified <name>.
Note that, the cache feature is disabled if the model is operating on a transaction.
func (*ContestantDao) Chunk ¶
func (d *ContestantDao) Chunk(limit int, callback func(entities []*model.Contestant, err error) bool)
Chunk iterates the table with given size and callback function.
func (*ContestantDao) Ctx ¶
func (d *ContestantDao) Ctx(ctx context.Context) *ContestantDao
Ctx is a chaining function, which creates and returns a new DB that is a shallow copy of current DB object and with given context in it. Note that this returned DB object can be used only once, so do not assign it to a global or package variable for long using.
func (*ContestantDao) Data ¶
func (d *ContestantDao) Data(data ...interface{}) *ContestantDao
Data sets the operation data for the model. The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc. Eg: Data("uid=10000") Data("uid", 10000) Data(g.Map{"uid": 10000, "name":"john"}) Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
func (*ContestantDao) Fields ¶
func (d *ContestantDao) Fields(fieldNamesOrMapStruct ...interface{}) *ContestantDao
Fields sets the operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*ContestantDao) FieldsEx ¶
func (d *ContestantDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ContestantDao
FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*ContestantDao) Filter ¶
func (d *ContestantDao) Filter() *ContestantDao
Filter marks filtering the fields which does not exist in the fields of the operated table.
func (*ContestantDao) FindAll ¶
func (d *ContestantDao) FindAll(where ...interface{}) ([]*model.Contestant, error)
FindAll retrieves and returns Result by by M.WherePri and M.All. Also see M.WherePri and M.All.
func (*ContestantDao) FindOne ¶
func (d *ContestantDao) FindOne(where ...interface{}) (*model.Contestant, error)
FindOne retrieves and returns a single Record by M.WherePri and M.One. Also see M.WherePri and M.One.
func (*ContestantDao) Group ¶
func (d *ContestantDao) Group(groupBy string) *ContestantDao
Group sets the "GROUP BY" statement for the model.
func (*ContestantDao) InnerJoin ¶
func (d *ContestantDao) InnerJoin(table ...string) *ContestantDao
InnerJoin does "INNER JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ContestantDao) LeftJoin ¶
func (d *ContestantDao) LeftJoin(table ...string) *ContestantDao
LeftJoin does "LEFT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ContestantDao) Limit ¶
func (d *ContestantDao) Limit(limit ...int) *ContestantDao
Limit sets the "LIMIT" statement for the model. The parameter <limit> can be either one or two number, if passed two number is passed, it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" statement.
func (*ContestantDao) LockShared ¶
func (d *ContestantDao) LockShared() *ContestantDao
LockShared sets the lock in share mode for current operation.
func (*ContestantDao) LockUpdate ¶
func (d *ContestantDao) LockUpdate() *ContestantDao
LockUpdate sets the lock for update for current operation.
func (*ContestantDao) Master ¶
func (d *ContestantDao) Master() *ContestantDao
Master marks the following operation on master node.
func (*ContestantDao) Offset ¶
func (d *ContestantDao) Offset(offset int) *ContestantDao
Offset sets the "OFFSET" statement for the model. It only makes sense for some databases like SQLServer, PostgreSQL, etc.
func (*ContestantDao) OmitEmpty ¶
func (d *ContestantDao) OmitEmpty() *ContestantDao
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*ContestantDao) One ¶
func (d *ContestantDao) One(where ...interface{}) (*model.Contestant, error)
One retrieves one record from table and returns the result as *model.Contestant. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*ContestantDao) Option ¶
func (d *ContestantDao) Option(option int) *ContestantDao
Option sets the extra operation option for the model.
func (*ContestantDao) Or ¶
func (d *ContestantDao) Or(where interface{}, args ...interface{}) *ContestantDao
Or adds "OR" condition to the where statement.
func (*ContestantDao) Order ¶
func (d *ContestantDao) Order(orderBy ...string) *ContestantDao
Order sets the "ORDER BY" statement for the model.
func (*ContestantDao) Page ¶
func (d *ContestantDao) Page(page, limit int) *ContestantDao
Page sets the paging number for the model. The parameter <page> is started from 1 for paging. Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
func (*ContestantDao) RightJoin ¶
func (d *ContestantDao) RightJoin(table ...string) *ContestantDao
RightJoin does "RIGHT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ContestantDao) Scan ¶
func (d *ContestantDao) Scan(pointer interface{}, where ...interface{}) error
Scan automatically calls Struct or Structs function according to the type of parameter <pointer>. It calls function Struct if <pointer> is type of *struct/**struct. It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Scan(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Scan(&user)
users := ([]User)(nil) err := dao.User.Scan(&users)
users := ([]*User)(nil) err := dao.User.Scan(&users)
func (*ContestantDao) Slave ¶
func (d *ContestantDao) Slave() *ContestantDao
Slave marks the following operation on slave node. Note that it makes sense only if there's any slave node configured.
func (*ContestantDao) Struct ¶
func (d *ContestantDao) Struct(pointer interface{}, where ...interface{}) error
Struct retrieves one record from table and converts it into given struct. The parameter <pointer> should be type of *struct/**struct. If type **struct is given, it can create the struct internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Struct(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Struct(&user)
func (*ContestantDao) Structs ¶
func (d *ContestantDao) Structs(pointer interface{}, where ...interface{}) error
Structs retrieves records from table and converts them into given struct slice. The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct slice internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not empty.
Eg: users := ([]User)(nil) err := dao.User.Structs(&users)
users := ([]*User)(nil) err := dao.User.Structs(&users)
func (*ContestantDao) TX ¶
func (d *ContestantDao) TX(tx *gdb.TX) *ContestantDao
TX sets the transaction for current operation.
func (*ContestantDao) Unscoped ¶
func (d *ContestantDao) Unscoped() *ContestantDao
Unscoped enables/disables the soft deleting feature.
func (*ContestantDao) Where ¶
func (d *ContestantDao) Where(where interface{}, args ...interface{}) *ContestantDao
Where sets the condition statement for the model. The parameter <where> can be type of string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, multiple conditions will be joined into where statement using "AND". Eg: Where("uid=10000") Where("uid", 10000) Where("money>? AND name like ?", 99999, "vip_%") Where("uid", 1).Where("name", "john") Where("status IN (?)", g.Slice{1,2,3}) Where("age IN(?,?)", 18, 50) Where(User{ Id : 1, UserName : "john"})
func (*ContestantDao) WherePri ¶
func (d *ContestantDao) WherePri(where interface{}, args ...interface{}) *ContestantDao
WherePri does the same logic as M.Where except that if the parameter <where> is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given <where> parameter as "123", the WherePri function treats the condition as "id=123", but M.Where treats the condition as string "123".
type MatchDao ¶
MatchDao is the manager for logic model data accessing and custom defined data operations functions management.
func (*MatchDao) All ¶
All does "SELECT FROM ..." statement for the model. It retrieves the records from table and returns the result as []*model.Match. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*MatchDao) Cache ¶
Cache sets the cache feature for the model. It caches the result of the sql, which means if there's another same sql request, it just reads and returns the result from cache, it but not committed and executed into the database.
If the parameter <duration> < 0, which means it clear the cache with given <name>. If the parameter <duration> = 0, which means it never expires. If the parameter <duration> > 0, which means it expires after <duration>.
The optional parameter <name> is used to bind a name to the cache, which means you can later control the cache like changing the <duration> or clearing the cache with specified <name>.
Note that, the cache feature is disabled if the model is operating on a transaction.
func (*MatchDao) Ctx ¶
Ctx is a chaining function, which creates and returns a new DB that is a shallow copy of current DB object and with given context in it. Note that this returned DB object can be used only once, so do not assign it to a global or package variable for long using.
func (*MatchDao) Data ¶
Data sets the operation data for the model. The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc. Eg: Data("uid=10000") Data("uid", 10000) Data(g.Map{"uid": 10000, "name":"john"}) Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
func (*MatchDao) Fields ¶
Fields sets the operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*MatchDao) FieldsEx ¶
FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*MatchDao) Filter ¶
Filter marks filtering the fields which does not exist in the fields of the operated table.
func (*MatchDao) FindAll ¶
FindAll retrieves and returns Result by by M.WherePri and M.All. Also see M.WherePri and M.All.
func (*MatchDao) FindOne ¶
FindOne retrieves and returns a single Record by M.WherePri and M.One. Also see M.WherePri and M.One.
func (*MatchDao) InnerJoin ¶
InnerJoin does "INNER JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
func (*MatchDao) LeftJoin ¶
LeftJoin does "LEFT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
func (*MatchDao) Limit ¶
Limit sets the "LIMIT" statement for the model. The parameter <limit> can be either one or two number, if passed two number is passed, it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" statement.
func (*MatchDao) LockShared ¶
LockShared sets the lock in share mode for current operation.
func (*MatchDao) LockUpdate ¶
LockUpdate sets the lock for update for current operation.
func (*MatchDao) Offset ¶
Offset sets the "OFFSET" statement for the model. It only makes sense for some databases like SQLServer, PostgreSQL, etc.
func (*MatchDao) OmitEmpty ¶
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*MatchDao) One ¶
One retrieves one record from table and returns the result as *model.Match. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*MatchDao) Page ¶
Page sets the paging number for the model. The parameter <page> is started from 1 for paging. Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
func (*MatchDao) RightJoin ¶
RightJoin does "RIGHT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
func (*MatchDao) Scan ¶
Scan automatically calls Struct or Structs function according to the type of parameter <pointer>. It calls function Struct if <pointer> is type of *struct/**struct. It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Scan(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Scan(&user)
users := ([]User)(nil) err := dao.User.Scan(&users)
users := ([]*User)(nil) err := dao.User.Scan(&users)
func (*MatchDao) Slave ¶
Slave marks the following operation on slave node. Note that it makes sense only if there's any slave node configured.
func (*MatchDao) Struct ¶
Struct retrieves one record from table and converts it into given struct. The parameter <pointer> should be type of *struct/**struct. If type **struct is given, it can create the struct internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Struct(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Struct(&user)
func (*MatchDao) Structs ¶
Structs retrieves records from table and converts them into given struct slice. The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct slice internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not empty.
Eg: users := ([]User)(nil) err := dao.User.Structs(&users)
users := ([]*User)(nil) err := dao.User.Structs(&users)
func (*MatchDao) Where ¶
Where sets the condition statement for the model. The parameter <where> can be type of string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, multiple conditions will be joined into where statement using "AND". Eg: Where("uid=10000") Where("uid", 10000) Where("money>? AND name like ?", 99999, "vip_%") Where("uid", 1).Where("name", "john") Where("status IN (?)", g.Slice{1,2,3}) Where("age IN(?,?)", 18, 50) Where(User{ Id : 1, UserName : "john"})
func (*MatchDao) WherePri ¶
WherePri does the same logic as M.Where except that if the parameter <where> is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given <where> parameter as "123", the WherePri function treats the condition as "id=123", but M.Where treats the condition as string "123".
type RuleDao ¶
RuleDao is the manager for logic model data accessing and custom defined data operations functions management.
func (*RuleDao) All ¶
All does "SELECT FROM ..." statement for the model. It retrieves the records from table and returns the result as []*model.Rule. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*RuleDao) Cache ¶
Cache sets the cache feature for the model. It caches the result of the sql, which means if there's another same sql request, it just reads and returns the result from cache, it but not committed and executed into the database.
If the parameter <duration> < 0, which means it clear the cache with given <name>. If the parameter <duration> = 0, which means it never expires. If the parameter <duration> > 0, which means it expires after <duration>.
The optional parameter <name> is used to bind a name to the cache, which means you can later control the cache like changing the <duration> or clearing the cache with specified <name>.
Note that, the cache feature is disabled if the model is operating on a transaction.
func (*RuleDao) Ctx ¶
Ctx is a chaining function, which creates and returns a new DB that is a shallow copy of current DB object and with given context in it. Note that this returned DB object can be used only once, so do not assign it to a global or package variable for long using.
func (*RuleDao) Data ¶
Data sets the operation data for the model. The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc. Eg: Data("uid=10000") Data("uid", 10000) Data(g.Map{"uid": 10000, "name":"john"}) Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
func (*RuleDao) Fields ¶
Fields sets the operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*RuleDao) FieldsEx ¶
FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*RuleDao) Filter ¶
Filter marks filtering the fields which does not exist in the fields of the operated table.
func (*RuleDao) FindAll ¶
FindAll retrieves and returns Result by by M.WherePri and M.All. Also see M.WherePri and M.All.
func (*RuleDao) FindOne ¶
FindOne retrieves and returns a single Record by M.WherePri and M.One. Also see M.WherePri and M.One.
func (*RuleDao) InnerJoin ¶
InnerJoin does "INNER JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
func (*RuleDao) LeftJoin ¶
LeftJoin does "LEFT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
func (*RuleDao) Limit ¶
Limit sets the "LIMIT" statement for the model. The parameter <limit> can be either one or two number, if passed two number is passed, it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" statement.
func (*RuleDao) LockShared ¶
LockShared sets the lock in share mode for current operation.
func (*RuleDao) LockUpdate ¶
LockUpdate sets the lock for update for current operation.
func (*RuleDao) Offset ¶
Offset sets the "OFFSET" statement for the model. It only makes sense for some databases like SQLServer, PostgreSQL, etc.
func (*RuleDao) OmitEmpty ¶
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*RuleDao) One ¶
One retrieves one record from table and returns the result as *model.Rule. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*RuleDao) Page ¶
Page sets the paging number for the model. The parameter <page> is started from 1 for paging. Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
func (*RuleDao) RightJoin ¶
RightJoin does "RIGHT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
func (*RuleDao) Scan ¶
Scan automatically calls Struct or Structs function according to the type of parameter <pointer>. It calls function Struct if <pointer> is type of *struct/**struct. It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Scan(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Scan(&user)
users := ([]User)(nil) err := dao.User.Scan(&users)
users := ([]*User)(nil) err := dao.User.Scan(&users)
func (*RuleDao) Slave ¶
Slave marks the following operation on slave node. Note that it makes sense only if there's any slave node configured.
func (*RuleDao) Struct ¶
Struct retrieves one record from table and converts it into given struct. The parameter <pointer> should be type of *struct/**struct. If type **struct is given, it can create the struct internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Struct(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Struct(&user)
func (*RuleDao) Structs ¶
Structs retrieves records from table and converts them into given struct slice. The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct slice internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not empty.
Eg: users := ([]User)(nil) err := dao.User.Structs(&users)
users := ([]*User)(nil) err := dao.User.Structs(&users)
func (*RuleDao) Where ¶
Where sets the condition statement for the model. The parameter <where> can be type of string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, multiple conditions will be joined into where statement using "AND". Eg: Where("uid=10000") Where("uid", 10000) Where("money>? AND name like ?", 99999, "vip_%") Where("uid", 1).Where("name", "john") Where("status IN (?)", g.Slice{1,2,3}) Where("age IN(?,?)", 18, 50) Where(User{ Id : 1, UserName : "john"})
func (*RuleDao) WherePri ¶
WherePri does the same logic as M.Where except that if the parameter <where> is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given <where> parameter as "123", the WherePri function treats the condition as "id=123", but M.Where treats the condition as string "123".
type ScoreDao ¶
ScoreDao is the manager for logic model data accessing and custom defined data operations functions management.
func (*ScoreDao) All ¶
All does "SELECT FROM ..." statement for the model. It retrieves the records from table and returns the result as []*model.Score. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*ScoreDao) Cache ¶
Cache sets the cache feature for the model. It caches the result of the sql, which means if there's another same sql request, it just reads and returns the result from cache, it but not committed and executed into the database.
If the parameter <duration> < 0, which means it clear the cache with given <name>. If the parameter <duration> = 0, which means it never expires. If the parameter <duration> > 0, which means it expires after <duration>.
The optional parameter <name> is used to bind a name to the cache, which means you can later control the cache like changing the <duration> or clearing the cache with specified <name>.
Note that, the cache feature is disabled if the model is operating on a transaction.
func (*ScoreDao) Ctx ¶
Ctx is a chaining function, which creates and returns a new DB that is a shallow copy of current DB object and with given context in it. Note that this returned DB object can be used only once, so do not assign it to a global or package variable for long using.
func (*ScoreDao) Data ¶
Data sets the operation data for the model. The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc. Eg: Data("uid=10000") Data("uid", 10000) Data(g.Map{"uid": 10000, "name":"john"}) Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
func (*ScoreDao) Fields ¶
Fields sets the operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*ScoreDao) FieldsEx ¶
FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*ScoreDao) Filter ¶
Filter marks filtering the fields which does not exist in the fields of the operated table.
func (*ScoreDao) FindAll ¶
FindAll retrieves and returns Result by by M.WherePri and M.All. Also see M.WherePri and M.All.
func (*ScoreDao) FindOne ¶
FindOne retrieves and returns a single Record by M.WherePri and M.One. Also see M.WherePri and M.One.
func (*ScoreDao) InnerJoin ¶
InnerJoin does "INNER JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ScoreDao) LeftJoin ¶
LeftJoin does "LEFT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ScoreDao) Limit ¶
Limit sets the "LIMIT" statement for the model. The parameter <limit> can be either one or two number, if passed two number is passed, it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" statement.
func (*ScoreDao) LockShared ¶
LockShared sets the lock in share mode for current operation.
func (*ScoreDao) LockUpdate ¶
LockUpdate sets the lock for update for current operation.
func (*ScoreDao) Offset ¶
Offset sets the "OFFSET" statement for the model. It only makes sense for some databases like SQLServer, PostgreSQL, etc.
func (*ScoreDao) OmitEmpty ¶
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*ScoreDao) One ¶
One retrieves one record from table and returns the result as *model.Score. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*ScoreDao) Page ¶
Page sets the paging number for the model. The parameter <page> is started from 1 for paging. Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
func (*ScoreDao) RightJoin ¶
RightJoin does "RIGHT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
func (*ScoreDao) Scan ¶
Scan automatically calls Struct or Structs function according to the type of parameter <pointer>. It calls function Struct if <pointer> is type of *struct/**struct. It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Scan(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Scan(&user)
users := ([]User)(nil) err := dao.User.Scan(&users)
users := ([]*User)(nil) err := dao.User.Scan(&users)
func (*ScoreDao) Slave ¶
Slave marks the following operation on slave node. Note that it makes sense only if there's any slave node configured.
func (*ScoreDao) Struct ¶
Struct retrieves one record from table and converts it into given struct. The parameter <pointer> should be type of *struct/**struct. If type **struct is given, it can create the struct internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Struct(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Struct(&user)
func (*ScoreDao) Structs ¶
Structs retrieves records from table and converts them into given struct slice. The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct slice internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not empty.
Eg: users := ([]User)(nil) err := dao.User.Structs(&users)
users := ([]*User)(nil) err := dao.User.Structs(&users)
func (*ScoreDao) Where ¶
Where sets the condition statement for the model. The parameter <where> can be type of string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, multiple conditions will be joined into where statement using "AND". Eg: Where("uid=10000") Where("uid", 10000) Where("money>? AND name like ?", 99999, "vip_%") Where("uid", 1).Where("name", "john") Where("status IN (?)", g.Slice{1,2,3}) Where("age IN(?,?)", 18, 50) Where(User{ Id : 1, UserName : "john"})
func (*ScoreDao) WherePri ¶
WherePri does the same logic as M.Where except that if the parameter <where> is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given <where> parameter as "123", the WherePri function treats the condition as "id=123", but M.Where treats the condition as string "123".
type UserDao ¶
UserDao is the manager for logic model data accessing and custom defined data operations functions management.
func (*UserDao) All ¶
All does "SELECT FROM ..." statement for the model. It retrieves the records from table and returns the result as []*model.User. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*UserDao) Cache ¶
Cache sets the cache feature for the model. It caches the result of the sql, which means if there's another same sql request, it just reads and returns the result from cache, it but not committed and executed into the database.
If the parameter <duration> < 0, which means it clear the cache with given <name>. If the parameter <duration> = 0, which means it never expires. If the parameter <duration> > 0, which means it expires after <duration>.
The optional parameter <name> is used to bind a name to the cache, which means you can later control the cache like changing the <duration> or clearing the cache with specified <name>.
Note that, the cache feature is disabled if the model is operating on a transaction.
func (*UserDao) Ctx ¶
Ctx is a chaining function, which creates and returns a new DB that is a shallow copy of current DB object and with given context in it. Note that this returned DB object can be used only once, so do not assign it to a global or package variable for long using.
func (*UserDao) Data ¶
Data sets the operation data for the model. The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc. Eg: Data("uid=10000") Data("uid", 10000) Data(g.Map{"uid": 10000, "name":"john"}) Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
func (*UserDao) Fields ¶
Fields sets the operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*UserDao) FieldsEx ¶
FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','. The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
func (*UserDao) Filter ¶
Filter marks filtering the fields which does not exist in the fields of the operated table.
func (*UserDao) FindAll ¶
FindAll retrieves and returns Result by by M.WherePri and M.All. Also see M.WherePri and M.All.
func (*UserDao) FindOne ¶
FindOne retrieves and returns a single Record by M.WherePri and M.One. Also see M.WherePri and M.One.
func (*UserDao) InnerJoin ¶
InnerJoin does "INNER JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
func (*UserDao) LeftJoin ¶
LeftJoin does "LEFT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
func (*UserDao) Limit ¶
Limit sets the "LIMIT" statement for the model. The parameter <limit> can be either one or two number, if passed two number is passed, it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]" statement.
func (*UserDao) LockShared ¶
LockShared sets the lock in share mode for current operation.
func (*UserDao) LockUpdate ¶
LockUpdate sets the lock for update for current operation.
func (*UserDao) Offset ¶
Offset sets the "OFFSET" statement for the model. It only makes sense for some databases like SQLServer, PostgreSQL, etc.
func (*UserDao) OmitEmpty ¶
OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers the data and where attributes for empty values.
func (*UserDao) One ¶
One retrieves one record from table and returns the result as *model.User. It returns nil if there's no record retrieved with the given conditions from table.
The optional parameter <where> is the same as the parameter of M.Where function, see M.Where.
func (*UserDao) Page ¶
Page sets the paging number for the model. The parameter <page> is started from 1 for paging. Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
func (*UserDao) RightJoin ¶
RightJoin does "RIGHT JOIN ... ON ..." statement on the model. The parameter <table> can be joined table and its joined condition, and also with its alias name, like: Table("user").RightJoin("user_detail", "user_detail.uid=user.uid") Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
func (*UserDao) Scan ¶
Scan automatically calls Struct or Structs function according to the type of parameter <pointer>. It calls function Struct if <pointer> is type of *struct/**struct. It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Scan(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Scan(&user)
users := ([]User)(nil) err := dao.User.Scan(&users)
users := ([]*User)(nil) err := dao.User.Scan(&users)
func (*UserDao) Slave ¶
Slave marks the following operation on slave node. Note that it makes sense only if there's any slave node configured.
func (*UserDao) Struct ¶
Struct retrieves one record from table and converts it into given struct. The parameter <pointer> should be type of *struct/**struct. If type **struct is given, it can create the struct internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not nil.
Eg: user := new(User) err := dao.User.Where("id", 1).Struct(user)
user := (*User)(nil) err := dao.User.Where("id", 1).Struct(&user)
func (*UserDao) Structs ¶
Structs retrieves records from table and converts them into given struct slice. The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct slice internally during converting.
The optional parameter <where> is the same as the parameter of Model.Where function, see Model.Where.
Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions from table and <pointer> is not empty.
Eg: users := ([]User)(nil) err := dao.User.Structs(&users)
users := ([]*User)(nil) err := dao.User.Structs(&users)
func (*UserDao) Where ¶
Where sets the condition statement for the model. The parameter <where> can be type of string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times, multiple conditions will be joined into where statement using "AND". Eg: Where("uid=10000") Where("uid", 10000) Where("money>? AND name like ?", 99999, "vip_%") Where("uid", 1).Where("name", "john") Where("status IN (?)", g.Slice{1,2,3}) Where("age IN(?,?)", 18, 50) Where(User{ Id : 1, UserName : "john"})
func (*UserDao) WherePri ¶
WherePri does the same logic as M.Where except that if the parameter <where> is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given <where> parameter as "123", the WherePri function treats the condition as "id=123", but M.Where treats the condition as string "123".