Reputation:
This is my search code. I am using this code for get Card from firestore. I am trying to set sorting by date my cards.
How can I do that. Thanks for help.
class SearchService {
List<Future<QuerySnapshot>> searchByName() {
return [
Firestore.instance
.collection('dis')
.where('no')
.getDocuments(),
];
}
}
Upvotes: 0
Views: 1794
Reputation: 317968
A "where" clause isn't going to sort the query results for you. You will need to use orderBy for that. You will also need to know the name of the date field to use for ordering, as shown in the documentation.
Firestore.instance
.collection('dis')
.orderBy('date')
.getDocuments(),
If you don't have a field that stores a date for each document, you won't be able to order the results.
Upvotes: 3