Preview:
   let User = Auth.auth().currentUser
        if let user = User{
            let db = Firestore.firestore()
            db.collection("Appointments").whereField("patient_id", isEqualTo: user.uid).getDocuments { [self] (document, error) in
                guard let data = document?.documents else {
                    return
                }
                      for d in data{
                    self.chatStatus = d.get("chat_status") as? String ?? ""
                    self.startTime = d.get("start_time") as? String ?? ""
                }
                      //updating data
                    let document = document!.documents.first
                    document?.reference.updateData([
                                   "chat_status": "Started"
                               ])
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