store unique events with Firebase and Swift

I am building an app for iOS with swift and Cloud Firestore (firebase) that allows the user to create home inspection reports. On the first page, the initial data is entered into text fields: name, address, photo of home etc. Once that data is entered and the "create new report" button is pressed. How do I make sure each report created is a totally unique event (or unique document?) that can be recalled later? So the next time one creates a new report, their data is separate and contained in its own container.

Add Comment
1 Answer(s)

Whenever you call addDocument to add a new document, Firestore generates a random, unique ID for that new document. So that sounds perfect for your use-case: whenever the user clicks the create new report button, you add a document by calling addDocument and then use that document’s ID as the identifier for that report.

Answered on September 1, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.