Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = sqlx.ErrNotFound
ErrNotFound types an alias for sqlx.ErrNotFound
Functions ¶
This section is empty.
Types ¶
type Student ¶
type Student struct {
Id int64 `db:"id"`
Class string `db:"class"`
Name string `db:"name"`
Age sql.NullInt64 `db:"age"`
Score sql.NullFloat64 `db:"score"`
CreateTime time.Time `db:"create_time"`
UpdateTime sql.NullTime `db:"update_time"`
}
Student only for test
type StudentModel ¶
type StudentModel interface {
Insert(data Student) (sql.Result, error)
FindOne(id int64) (*Student, error)
FindOneByClassName(class, name string) (*Student, error)
Update(data Student) error
// only for test
Delete(id int64, className, studentName string) error
}
StudentModel only for test
func NewStudentModel ¶
func NewStudentModel(conn sqlx.SqlConn, c cache.CacheConf) StudentModel
NewStudentModel only for test
type User ¶
type User struct {
ID int64 `db:"id"`
User string `db:"user"` // user
Name string `db:"name"` // user name
Password string `db:"password"` // user password
Mobile string `db:"mobile"` // user mobile
Gender string `db:"gender"` // male | female | unknown
Nickname string `db:"nickname"` // user nickname
CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"`
}
User defines an data structure for mysql
type UserModel ¶
type UserModel interface {
Insert(data User) (sql.Result, error)
FindOne(id int64) (*User, error)
FindOneByUser(user string) (*User, error)
FindOneByMobile(mobile string) (*User, error)
FindOneByName(name string) (*User, error)
Update(data User) error
Delete(id int64) error
}
UserModel defines a model for user
func NewUserModel ¶
NewUserModel creates an instance for UserModel
Click to show internal directories.
Click to hide internal directories.