1

Why I cant use whereQuery in collectionGroup.

When I use whereQuery like that;

Query colRef = _firestore.collection("users");

    colRef = colRef.where("name", isEqualTo: widget.name);

Its working, but when I use whereQuery like that;

Query colRef = _firestore.collectionGroup("users");
    
        colRef = colRef.where("name", isEqualTo: widget.name);

Its not working, while geting the data, I query whether there is an error by using hasError and if else, and I get an error. and I must use collectionGroup while getting data from firebase.

Is there a solution to use whereQuery in collectionGroup?

Firestore Index Settings

I guess I need to somehow enable the disabled options here, but I don't know how to do it.

In summary I want all users in the application to have access to all kinds of data that I specify in the collection Group.

Rkdio
  • 153
  • 2
  • 13
  • Where clauses work with collection group queries, same as for regular queries. Did you define an index for the query and set the rules as shown here? https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query – Frank van Puffelen Oct 22 '21 at 23:12
  • Please say more than "it is not working". If you are getting an error message, share that message with us. If you are getting an empty result set, then say how that is different than what you expected in the results. You can edit your question to add information by using the edit button at the bottom. – Doug Stevenson Oct 22 '21 at 23:25
  • Have you created the [corresponding index](https://stackoverflow.com/questions/53790175/why-does-this-firestore-query-require-an-index/53790652)? – Alex Mamo Oct 23 '21 at 10:49
  • While pulling the data, I query whether there is an error by using hasError and if else, and I get an error. – Rkdio Oct 23 '21 at 12:32
  • I didnt define an index or I didnt set the rules I will check them and try again thanks. – Rkdio Oct 23 '21 at 12:35
  • I did some changes but nothing fixed – Rkdio Oct 23 '21 at 12:53
  • In summary I want all users in the application to have access to all kinds of data that I specify in the collection Group. – Rkdio Oct 23 '21 at 13:18

1 Answers1

1

I need to set the composite and exemption part at the same time, when I set both parts according to the paths I want to query, the problem was solved.

Rkdio
  • 153
  • 2
  • 13
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 23 '21 at 20:14