fix: duplicate rule when query by page

This commit is contained in:
zhongwencool 2022-07-22 15:46:12 +08:00
parent b7bcb9ea11
commit 91a7022e83
1 changed files with 6 additions and 5 deletions

View File

@ -98,11 +98,12 @@ node_query(Node, Params, {Tab, QsSchema}, QueryFun, SortFun) ->
true -> Meta#{count => count(Tab), hasnext => length(Rows) > Limit};
_ -> Meta#{count => -1, hasnext => length(Rows) > Limit}
end,
NRows = case SortFun of
undefined -> Rows;
_ -> lists:sort(SortFun, Rows)
Data0 = lists:sublist(Rows, Limit),
Data = case SortFun of
undefined -> Data0;
_ -> lists:sort(SortFun, Data0)
end,
#{meta => NMeta, data => lists:sublist(NRows, Limit)}.
#{meta => NMeta, data => Data}.
%% @private
do_query(Node, Qs, {M,F}, Start, Limit) when Node =:= node() ->