There isn't any function to check if a field exists in a document. You'll have to fetch the document and check for it's existence:
let docRef = Firestore.firestore().collection(user!.uid).document(docID)
docRef.getDocument { (document, error) in
if let document = document, document.exists {
let data = document.data()
// Check if the field exists in data
} else {
print("Document does not exist")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.