Mr. Joe
Mr. Joe

Reputation: 11

Why I have no results with a collection group query?

I'm using for first time collection groups querys on firestore in my web application but I can't retrive any data and I don't know why

I'm using Firebase SDK 7.6.1 and I have created the indexes correctly i think. This is my Collection data structure:

Firestore Collection Data Structure

And this are my Indexes:

Firestore Indexes

And finally the code with I'm trying to retrieving data is:

  doc = this.database.collectionGroup('Authors')
  .where('Name','==',this.TextParams.trim().toLowerCase());

I expected to retrieve the documents where the author name is equal to my TextParams variable

Upvotes: 0

Views: 162

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317750

In your screenshot, Authors is not a subcollection, it's an array type field. Since it's not a subcollection, a collection group query won't work at all. Also, it's currently not possible to search among array field items.

What you will have to do is actually put your Authors into a subcollection.

Upvotes: 1

Related Questions