Is there an easy way to add a value to an array in Firestore that already exists? I know arrayUnion()
will not add a value to the array if it already exists, and I have read older replies that the only way to do this is to read the entire document, and then completely re-write the array, but that is incredibly inefficient (and could get expensive). Is there not a better way to do this in Firebase?
For example, if my value for update
already exists in my array, I still want it to add it to my array.
'unitsLog': FieldValue.arrayUnion([update])