title: How do I delete a Firestore Document from a List in SwiftUI
body: <p>Here is my view model</p>
  <pre><code>import FirebaseFirestore
  import FirebaseFirestoreSwift
  
  struct Todo: Codable, Identifiable, Hashable {
      @DocumentID var id: String?
      var todoDetais: String?
  }
  </code></pre>
  <p>This is how I'm showing the list ignore the typo in &quot;details&quot;.</p>
  <pre><code>var body: some View {
      NavigationView {
          List {
              ForEach(viewModel.todos, id: \.self) { todo in
                  VStack{
                      Text(todo.todoDetais!)
                  }
              }
              .onDelete(perform: delete)
          }
  </code></pre>
  <p>My fetch data and mapping.</p>
  <pre><code>    func fetchData() {
      db.collection(&quot;todos&quot;).addSnapshotListener { (querySnapshot, error) in
          guard let documents = querySnapshot?.documents else {
              print(&quot;No documents&quot;)
              return
          }
          
          self.todos = documents.map { (QueryDocumentSnapshot)  -&gt; Todo in
              let data = QueryDocumentSnapshot.data()
              let todoDetails = data[&quot;todo&quot;] as? String ?? &quot;&quot;
              
              return Todo(todoDetais: todoDetails)
          }
      }
  }
  </code></pre>
  <p>The delete logic, I can remove from a list but how do I delete from Firestore?</p>
  <pre><code>    func delete(at offsets: IndexSet) {
      viewModel.todos.remove(atOffsets: offsets)
      
      //I need to delete a firestore document at the index im removing at?
      
  }
  </code></pre>