I am trying to fetch the data from my Firestore collection and now what i want to do is to sort the documents by one of the fields say "dateCode" Attaching codes below:
func getDescOrderData(completion: @escaping ([String:Any]) -> Void) {
var dictInfo = [String:Any]()
Firestore..collection("OldData").order(by: "dateCode", descending: true)
.whereField("dateCode", isLessThanOrEqualTo: “Mon”)
.whereField("studentId", isEqualTo: self.studentId)
.getDocuments { (querySnapshot, error) in
if let error = error {
print("Old History Data error: \(error.localizedDescription)")
return
}
if let snapshot = querySnapshot {
for document in snapshot.documents {
dictInfo.append(document.data())
}
completion(dictInfo)
}
}
}
But i got error given below:-
Old History Data error: The query requires an index. You can create it here: https://console.firebase.googl.................
Any help would be greatly appreciated.