예제 #1
0
파일: user.go 프로젝트: orion003/leaguelog
func (repo *PgRepository) FindAllUsers() ([]model.User, error) {
	rows, err := repo.manager.db.Query(`SELECT id, email, password, salt, created, modified
        FROM user0`)

	if err != nil {
		return []model.User{}, err
	}

	var users []model.User
	for rows.Next() {
		user, err := marshal.User(rows)
		if err != nil {
			return []model.User{}, err
		}

		if users == nil {
			users = make([]model.User, 1, 10)
		}

		users = append(users, *user)
	}

	err = rows.Err()
	if err != nil {
		return []model.User{}, err
	}

	return users, nil
}
예제 #2
0
파일: user.go 프로젝트: orion003/leaguelog
func (repo *PgRepository) FindUserByEmail(email string) (*model.User, error) {
	row := repo.manager.db.QueryRow(`SELECT id, email, password, salt, created, modified
        FROM user0
        WHERE email = $1`, email)

	user, err := marshal.User(row)

	return user, err
}