// FetchManyUsers retrieves multiple users from the underlying data store by
// the provided query.
// Int return value specifies the total page count.
FetchManyUsers retrieves multiple users from the underlying data store by
the provided query.
Int return value specifies the total page count.
// FetchManyUsers retrieves multiple users from the underlying data store by // the provided query . // Int return value specifies the total page count .
func (s *Store) FetchManyUsers(ctx context.Context, qr httpflow.Query) ([]user.User, int, error) {
	err := qr.Validate(user.CheckFilterKey, user.CheckSortKey)
	if err != nil {
		return nil, 0, err
	}
	ord := "desc"
	if qr.Asc {
		ord = "asc"
	}
	name := fmt.Sprintf("select_users_by_%s_%s_%s", qr.FilterBy, ord, qr.SortBy)
	data := []struct {
		User      *user.Core `db:"user"`
		PageCount int        `db:"page_count"`
	}{}
	err = s.q.SelectContext(ctx, s.db, &data, name, qr.FilterVal, qr.Limit, qr.Limit*(qr.Page-1))
	if err != nil {
		return nil, 0, detectErr(err)
	}
	usrs := make([]user.User, len(data))
	for i, datum := range data {
		usrs[i] = datum.User
	}
	return usrs, data[0].PageCount, nil
}
func ( s * Store ) FetchManyUsers ( ctx context . Context , qr httpflow . Query ) ( [ ] user . User , int , error ) { err := qr . Validate ( user . CheckFilterKey , user . CheckSortKey ) if err != nil { return nil , 0 , err } ord := " " if qr . Asc { ord = " " } name := fmt . Sprintf ( " " , qr . FilterBy , ord , qr . SortBy ) data := [ ] struct { User * user . Core `db:"user"` PageCount int `db:"page_count"` } { } err = s . q . SelectContext ( ctx , s . db , & data , name , qr . FilterVal , qr . Limit , qr . Limit * ( qr . Page - 1 ) ) if err != nil { return nil , 0 , detectErr ( err ) } usrs := make ( [ ] user . User , len ( data ) ) for i , datum := range data { usrs [ i ] = datum . User } return usrs , data [ 0 ] . PageCount , nil }
FetchManyUsers retrieves multiple users from the underlying data store by
the provided query.
FetchManyUsers retrieves multiple users from the underlying data store by the provided query .