When possible, use limit to restrict the number of documents your queries can return.
Now we are ready to deserialize database objects into Swift structs.
Add the following code after the second Spacer in frontView: if! Replace var card: Card with: var cardViewModel: CardViewModel This lets the view use a view model instead of a Card model directly.
It uses collections and documents to structure data.
Getting Started with Cloud Firestore and SwiftUI raywenderlich.
In addition, we should keep the main chat document relatively small to also minimize data load times.