0

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);

  }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
nady
  • 1
  • 1

1 Answers1

1

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

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807