Jerry Seigle
Jerry Seigle

Reputation: 457

Firestore orderBy descending is not working

When using Firestore I get an error only when I use .orderBy
error message is:
Uncaught Error in snapshot listener: [FirebaseError: no matching index found.]

todoRef
      .where("owner", "==", firebase.auth().currentUser.uid)
      .where("date", "==", props.date)
      .orderBy("description", "desc")
      .onSnapshot((querySnapshot) => {
        const data = [];
        querySnapshot.forEach((doc) => {
          const d = {
            id: doc.id,
            ...doc.data(),
          };
          data.push(d);
        });
        //console.log("coming from function", data);
        setData(data);
        return data;
      });

Upvotes: 0

Views: 1059

Answers (2)

Francesco Clementi
Francesco Clementi

Reputation: 2102

ANDROID On your terminal type:

adb logcat

or open logcat on Android studio, you will find a log with the error, reporting the url to create automatically the index required.

IOS Open xCode, go to logs and you will find a log with error, reporting the url to create automatically the index required.

If the url doesn't show, it's a known bug on firebase sdk. Follow this issue to get any update: https://github.com/firebase/firebase-js-sdk/issues/5152

If you don't want to wait just create manually the index with the console.

Upvotes: 1

squish
squish

Reputation: 1116

You need to create the index in your firebase console. Copy the link that has been printed into the console.

Upvotes: 1

Related Questions