getSubCollection method

Future<List<QueryDocumentSnapshot<Object?>>> getSubCollection(
  1. String collectionPath,
  2. String docId,
  3. String subCollection
)

Get all subdocuments from a subcollection.

collectionPath - The path of the parent collection. docId - The ID of the parent document. subCollection - The name of the subcollection within the parent document.

Returns a list of QueryDocumentSnapshot containing all subdocuments.

Implementation

Future<List<QueryDocumentSnapshot>> getSubCollection(
    String collectionPath, String docId, String subCollection) async {
  QuerySnapshot querySnapshot = await _db.collection(collectionPath).doc(docId).collection(subCollection).get();
  return querySnapshot.docs;
}