updateSubCollectionsDocument method

Future<bool> updateSubCollectionsDocument({
  1. required String collection,
  2. required String documentId,
  3. required String subCollection,
  4. required String subCollectionDocumentId,
  5. required Map<String, dynamic> update,
})

Implementation

Future<bool> updateSubCollectionsDocument({
  required String collection,
  required String documentId,
  required String subCollection,
  required String subCollectionDocumentId,
  required Map<String, dynamic> update,
}) async {
  try {
    await _firebaseFirestore
        .collection(collection)
        .doc(documentId)
        .collection(subCollection)
        .doc(subCollectionDocumentId)
        .update(update);
    _loggingService.log('FirestoreGenericService.setDocument: Update. Collection $collection, CollectionDocID: $documentId,'
        ' SubCollection: $subCollection, SubCollectionDocId: $subCollectionDocumentId, Update: $update');
    return true;
  } catch (e) {
    _loggingService.log(
      'FirestoreGenericService.setDocument: Update. Collection $collection, CollectionDocID: $documentId,'
      ' SubCollection: $subCollection, SubCollectionDocId: $subCollectionDocumentId,'
      ' Update: $update, Exception: ${e.toString()}',
      logType: LogType.error,
    );
    return false;
  }
}