Counting fields (specifically arrays) in a document
I have my document setup as:
Collection
------> Document
------> Array 1
Array 2
Array 3
I need to be able to count the number (as an Int) of arrays (or fields) in this document and be able to use it in a SwiftUI ForEach statement.
The problem is, I can't just use a specific number, because arrays are constantly being added and removed.
Since the arrays are constantly being added and removed, then you have two ways in which you can solve this. The first one would be to loop over the fields inside the document and check if the field is an array or not. Or you can simply increment/decrement a counter each time a new array is added or removed.