Lesson 8 from Module 1 of the CWC+ iOS Database course shows us how we can use completion handlers to check for errors when we interract with Firestore.
let db = Firestore.firestore()
let myCollection = db.collection("collection-name")
let doc = myCollection.addDocument(data: [:]) { error in
if let error = error {
print(error.localizedDescription)
} else {
return
}
}
We can use this when we try to delete a document, re:
doc.delete { (error) in
/// handle error
}
When updating a document, re:
doc.setData([:]) { error in
// handle error
}
doc.setData[:]) { error in
// handle error
}
Just keeping this here to remind myself for the future.