Reputation: 105
I'm querying firestore with:
this.todosCollection = this.afs.collection('todos', ref => ref.where('owner', '==', this.userId). orderBy('due', 'asc'));
The todo items is ordered in ascending order as I want, the problem is that todos without a due date (null) comes first. I want them to come last. Is this possible within the orderBy or other technique?
Upvotes: 9
Views: 2775
Reputation: 317657
That's the way the ordering of nulls is intended to work. The documentation makes this clear, and it can't be changed in the query itself.
If you want to change the ordering, then you will have to manually re-sort the documents on the client to support your preferred ordering. Or, you will have to make two queries, one that includes null and another that does not, then merge the results yourself.
Upvotes: 9