M1L7 : Deleting Data via Xcode

Following on from the previous lesson, this short video teaches us the different ways we can delete records (documents) and key-value pairs from our Firebase.

let db = Firestore.firestore()

let myDocument = db.collection("collection-name").document("document-name")
Lesson 7 Challenge

We can use the .updateData modifier to delete individual key-value pairs, thus:

myDocument.updateData([
    "key": FieldValue.delete()
])

To delete the entire document, we would use the .delete() modifier thus:

myDocument.delete()

It’s not adviseable to delete an entire collection from Xcode for some reason, but this can be done through the Firebase web console if necessary.