Skip to content

Commit 3951cdd

Browse files
committed
Use the new boss_db:find/3 API
1 parent f7e145a commit 3951cdd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/controller/cb_admin_model_controller.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ model('GET', [ModelName, PageName], Authorization) ->
3131
Page = list_to_integer(PageName),
3232
Model = list_to_atom(ModelName),
3333
RecordCount = boss_db:count(Model),
34-
Records = boss_db:find(Model, [], ?RECORDS_PER_PAGE, (Page - 1) * ?RECORDS_PER_PAGE, id, str_descending),
34+
Records = boss_db:find(Model, [], [{limit, ?RECORDS_PER_PAGE},
35+
{offset, (Page - 1) * ?RECORDS_PER_PAGE}, descending]),
3536
TopicString = string:join(lists:map(fun(Record) -> Record:id() ++ ".*" end, Records), ", "),
3637
AttributesWithDataTypes = lists:map(fun(Record) ->
3738
{Record:id(), lists:map(fun({Key, Val}) ->
@@ -52,7 +53,7 @@ model('GET', [ModelName, PageName], Authorization) ->
5253

5354
csv('GET', [ModelName], Authorization) ->
5455
Model = list_to_atom(ModelName),
55-
[First|_] = Records = boss_db:find(Model, [], all, 0, id, str_descending),
56+
[First|_] = Records = boss_db:find(Model, [], [descending]),
5657
FirstLine = [lists:foldr(fun
5758
(Attr, []) ->
5859
[atom_to_list(Attr)];

0 commit comments

Comments
 (0)