Reputation: 27
how to search collection within collection firebase flutter?
how to search the collection within the collection firebase flutter?
Example
collection ="listOfDoctors"
document="sdfdfseewew"this id
collection="hospital"
document="sssfasf" this id
Fields
{
'':'',
'specialties':'h1',
'':'',
...
}
How do I search in specialties??
How do I get over iddocument the first??
getData() async {
final listOfDoctors = await FirebaseFirestore.instance
.collection('listOfDoctors')
.where('specialties', arrayContainsAny: ['h1'])
.get();
print(listOfDoctors.size);
}
Upvotes: 0
Views: 694
Reputation: 599591
If you want to search across all hospital
collections in the entire database, you can use a collection group query.
If you want to search all hospital
collections under a given path, have a look at the answer from samthecodingman here: CollectionGroupQuery but limit search to subcollections under a particular document
Upvotes: 1