Exemple #1
0
func AllUsersByAge(age int) ([]User, error) {
	users := userStore{
		Fields: userFieldsAll,
	}

	err := DB.ArgsAll(&users, userInstance, userFieldsAll, USER_AGE, age)
	return users.Values, dberrs.NoRows(err, ErrNoUser)
}
Exemple #2
0
func UsersByAge(age, start, count int) ([]User, error) {
	users := userStore{
		Fields: userFieldsAll,
	}

	err := DB.ArgsLimit(&users, userInstance, userFieldsAll, USER_AGE, age, start, count)
	return users.Values, dberrs.NoRows(err, ErrNoUser)
}
Exemple #3
0
//gomodel queryMessageSQL = [
//  SELECT Value, Timing FROM message WHERE Id=? LIMIT 1
//]
func (d *DB) Query(id string) (value string, err error) {
	sc := gomodel.Query(d.stmtQueryMessage, nil, id)

	var time string
	err = sc.One(&value, &time)
	err = dberrs.NoRows(err, gotmsq.ErrNoMessage)
	if err != nil {
		return "", err
	}

	now := d.timingString(0)
	if now > time {
		return "", gotmsq.ErrNoMessage
	}

	return value, nil
}
Exemple #4
0
func (u *User) ById() error {
	err := DB.One(u, userFieldsExcpId, USER_ID)

	return dberrs.NoRows(err, ErrNoUser)
}