0
votes

Somebody has a solution for this:

I have a collection "stores". Every document from the collection "stores" has its fields like name, address, etc., and has a sub collection called "products". Every documento from the subcolletion "products" has its fields like name, price, etc., as shown in the print screen.

Using firestore, how can I search for a word in the "products" sub collection and retrieve the data from its parent? Search for a word in "products" and built a list with the documents of the collection "stores" that have in its subcollection "products" the searched word?

enter image description here

enter image description here

1

1 Answers

1
votes

I have something like this in my project:

Future<DocumentSnapshot> get() {
   return firestore.collection('products').document('Banana Frita').get();
}

Then, on my other class I would have something like this:

result = await firestoreBloc.get();
print(result.data['name']) // Banna Frita

Let me know if that works for you

PS: queria ter respondido em português :)