collectionPath method

CollectionReference<Map<String, dynamic>> collectionPath(
  1. List<String> pathParam
)

Implementation

CollectionReference<Map<String, dynamic>> collectionPath(
    List<String> pathParam) {
  var collection = db.collection(pathParam.removeAt(0));
  for (var i = 0; i < pathParam.length; i += 2) {
    if (i % 2 == 0 && i < pathParam.length - 1) {
      //collection
      var document = pathParam.removeAt(0);
      var col = pathParam.removeAt(0);
      collection = collection.doc(document).collection(col);
    }
  }

  return collection;
}