We are sending data to Firebase Firestore and need to write the data in a way that all information for a given date is stored in a single document. The sequence for writing data should be as follows:
- If the document does not exist in Firestore, it should be created.
- If the document already exists, the new data should be appended to that document without reading the current data, using the
arrayUnionfeature.
Currently, we are using the POST method to send data to the database. When creating a new document with each write, it works fine. However, when trying to write data into the same document, it doesn’t append as expected. We have also tried the PUT and PATCH methods to achieve this, but we are still facing the same issue—new data is not getting appended to the existing document.
Please help us resolve this issue.