Learn Courses My Dashboard

What is the best way of taking form data, converting it to an array and then updating a Firebase Database?

I am using Swift and Firebase to create an iOS app. Users can create accounts fine, however I’m creating a section where the user can upload products to the database. I want it so that it adds a new entry (example shown in the photo) containing the data from the form. The code I currently have is below, I am struggling to create a solution where the data from the form is added into a new section to the current users data, as an array.

Here is the code I am currently using to post data to the database once the fields have been validated and cleaned (removed whitespace).

        let db = Firestore.firestore()
        db.collection("users").addDocument(data: ["productname":productName, "producturl":URL,"productprice":productCurrency, "productdescription":descriptionofProduct,      "producttimeremaining":timeRemaining]) { (error) in
            if error != nil {
                // Show error message
                self.showError("Error saving user data")

Basically whenever a currently signed in user fills out a form I want it to add to the list of their account data shown in the image, as an array.

Any help would be greatly appreciated.