Skip to content

Commit

Permalink
Use the new boss_db:find/3 API
Browse files Browse the repository at this point in the history
  • Loading branch information
evanmiller committed Jul 22, 2012
1 parent f7e145a commit 3951cdd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/controller/cb_admin_model_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ model('GET', [ModelName, PageName], Authorization) ->
Page = list_to_integer(PageName),
Model = list_to_atom(ModelName),
RecordCount = boss_db:count(Model),
Records = boss_db:find(Model, [], ?RECORDS_PER_PAGE, (Page - 1) * ?RECORDS_PER_PAGE, id, str_descending),
Records = boss_db:find(Model, [], [{limit, ?RECORDS_PER_PAGE},
{offset, (Page - 1) * ?RECORDS_PER_PAGE}, descending]),
TopicString = string:join(lists:map(fun(Record) -> Record:id() ++ ".*" end, Records), ", "),
AttributesWithDataTypes = lists:map(fun(Record) ->
{Record:id(), lists:map(fun({Key, Val}) ->
Expand All @@ -52,7 +53,7 @@ model('GET', [ModelName, PageName], Authorization) ->

csv('GET', [ModelName], Authorization) ->
Model = list_to_atom(ModelName),
[First|_] = Records = boss_db:find(Model, [], all, 0, id, str_descending),
[First|_] = Records = boss_db:find(Model, [], [descending]),
FirstLine = [lists:foldr(fun
(Attr, []) ->
[atom_to_list(Attr)];
Expand Down

0 comments on commit 3951cdd

Please sign in to comment.