deekepMaks's avatar

cursor pagination order by

I am using mongodb and using cursor pagination. I am trying to use orders to sort the data I am getting. When I sort by _id I get correct data without any problem. When I start sorting, for example, by the created_at field, then I get the first page correct, and then emptiness, and there is no link to the previous page.

My code:

$sort = $request->get('sort');
$data = User::orderBy($sort, 'desc')->cursorPaginate(10);

What is the problem and how to solve it?

0 likes
1 reply

Please or to participate in this conversation.