Skip to content
Back

Query.orderAsc() with null values last

  • 0
  • Databases
  • Flutter
BomL97
20 Nov, 2023, 17:30

I'm sorting documents based on their due dates in ascending order. When I use the Query.orderAsc("dueDate") method, it rightly places documents with a null "dueDate" at the beginning. However, this creates a challenge for my pagination. I'm exploring whether there's a way or a workaround to arrange documents with null "dueDates" at the end of the list instead. Any suggestions or options for achieving this?

TL;DR
The user wants to sort documents based on their due dates in ascending order, but documents with null due dates are placed at the beginning, causing a challenge for pagination. They are looking for a way or workaround to arrange documents with null due dates at the end of the list instead.
ideclon
20 Nov, 2023, 19:01

You could filter out null valued records, and put them at the end? Not a very elegant solution, but it does the job

BomL97
21 Nov, 2023, 11:41

@ideclon That's how I am doing it currently. I hoped there was a more elegant solution. Thanks for your help anyways!!

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more