+1

On Jan 22, 2014, at 10:17, David Welton <[email protected]> wrote:

> Would it be worth including something like this directly in boss_db ?
> 
> paginate(Model, Conditions, Args) ->
>    Page = proplists:get_value(page, Args, 1),
>    PageSize = proplists:get_value(page_size, Args, ?DEFAULT_PAGE_SIZE),
>    ArgList = proplists:delete(page_size, proplists:delete(page, Args)) ++
>        [{offset, PageSize * (Page - 1)}, {limit, PageSize}],
>    Total = boss_db:count(Model, Conditions),
>    TotalPages = (Total div PageSize) + (case Total rem PageSize of
>                                             0 -> 0;
>                                             _ -> 1
>                                         end),
>    {Page, TotalPages, boss_db:find(Model, Conditions, ArgList)}.
> 
> -- 
> David N. Welton
> 
> http://www.welton.it/davidw/
> 
> http://www.dedasys.com/
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> Visit this group at http://groups.google.com/group/chicagoboss.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/chicagoboss/CA%2Bb9R_vQ9me_eTTwad7-fNqhyoqHD5N0xd8dLqAq8CUtwHECKg%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/80ED8459-BE68-49A9-8EA1-02D43E7D6731%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to