Uncaught Error in snapshot listener:, [FirebaseError: inequality filter property and first sort order must be the same: __name__ and date]

Viewed 27

I try to get some documents with the onSnpashot method and in the same times apply where (for filter the collection) and orderBy (for sort my results). I make a composite index (with documentId() field, and date) but it don't work... I hope you can help me. This is my structure

var ColRef = collection(DB_Firestore, "ListConv");
var q = query(ColRef, where(documentId(), "in", ["Oe4VQzzcLh1aKWedt7yU"]), orderBy("date", "desc"));
return onSnapshot(q, (snapshot) => {
  if(!snapshot.empty) {
    var changes = snapshot.docChanges();
    changes.map(change => {
      if(change.type == "added") {
        var conv = change.doc.data();
        conv["uid"] = change.doc.id;
        setConv(Conv => [...Conv, conv]);
      }
    });
    setLoadData(false);
  } else {
    setLoadData(false);
  }
})

Also I try to put the inside my hook's Array "Conv"; And get my handler in order to unsubscribe it. Thank's for all. Good Night !

0 Answers
Related