Preview:
// calling    
        StrutName.updateDocument("Users", "", dataToUpdate) { (isUpdated) in
            if isUpdated {
                    print("Success")
            } else {
                print("Found Error While Updating")
            }
        }

    public static func updateDocument (_ collectionName: String, _ documentId : String, _ dataToUpdate: [String: Any], completionHandler:@escaping (_ success:Bool) -> Void) {
        
        var documentID = ""
        
        SVProgressHUD.show()
        let User = Auth.auth().currentUser
        guard let user = User else {
            SVProgressHUD.dismiss()
            completionHandler(false)
            return
        }
        
        if documentId == "" {
            documentID = user.uid
        } else {
            documentID = documentId
        }
        
        let db = Firestore.firestore()
        db.collection(collectionName).document(documentID).setData(dataToUpdate, merge: true) { (error) in
            
            if error != nil {
                completionHandler(false)
                SVProgressHUD.dismiss()
                return
            }
            print("updated321")
            completionHandler(true)
            SVProgressHUD.dismiss()
        }
    }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter