StanfordSpezi / SpeziTemplateApplication

Template application demonstrating the usage of the Stanford Spezi framework.
https://stanfordspezi.github.io/SpeziTemplateApplication
MIT License
101 stars 19 forks source link

Use Codable for Firestore #48

Closed Supereg closed 9 months ago

Supereg commented 1 year ago

Problem

Currently, the SpeziTemplateApplication has a short code sample where it uploads data to Firestore. In this example we manually map our Model data to a [String: Any] dictionary and pass it to firebase. This is actively discouraged.

Solution

Firebase recommends using Swift's Codable to encode and decode Model data to and from Firestore. For more information see their documentation.

Additional context

This issue specifically talks about the following lines of code: https://github.com/StanfordSpezi/SpeziTemplateApplication/blob/092d4319c2defb3a2571db7e854e0205fa45c387/TemplateApplication/TemplateApplicationStandard.swift#L65-L75

Code of Conduct

Supereg commented 9 months ago

The mentioned lines of code are not part of the template application anymore. They were replaced through #58

PSchmiedmayer commented 9 months ago

Thank you @Supereg!