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/