示例#1
0
文件: helper.go 项目: thiennt/go-spa
func getToken(db *pg.Session, key string) (*Model, error) {
	resetToken, err := db.FindOne(&Model{}, "key = $1", key)
	if err != nil {
		return nil, err
	}
	return resetToken.(*Model), nil
}
示例#2
0
文件: helper.go 项目: thiennt/go-spa
func GetById(db *pg.Session, id int64) (*Model, error) {
	user, err := db.FindOne(&Model{}, "id = $1", id)
	if err != nil {
		return nil, err
	}
	return user.(*Model), nil
}
示例#3
0
文件: helper.go 项目: thiennt/go-spa
func GetByEmail(db *pg.Session, email string) (*Model, error) {
	user, err := db.FindOne(&Model{}, "email = $1", email)
	if err != nil {
		return nil, err
	}
	return user.(*Model), nil
}
示例#4
0
func GetById(db *pg.Session, id int) (*Model, error) {
	entity, err := db.FindOne(&Model{}, "id=$1", id)
	if err != nil {
		return nil, err
	}
	return entity.(*Model), nil
}