nady
nady

Reputation: 27

how to search collection within collection Cloud Firestore flutter?

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',

'':'',

...

}

enter image description here

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

Answers (1)

Frank van Puffelen
Frank van Puffelen

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

Related Questions