Increment value ios swift

PHOTO EMBED

Fri Mar 31 2023 07:07:52 GMT+0000 (Coordinated Universal Time)

Saved by @hasnat #ios #swift #increment

    func addPonits(_ fieldName : String, _ points : Int,_ message : String) {
        
        let data = [
            fieldName : FieldValue.increment(Int64(points))
        ]
        
        let db = Firestore.firestore()
        let docRef = db.collection("Games").document(gameID)
        docRef.updateData(data) { error in
            if let error = error {
                print("Error updating document: \(error.localizedDescription)")
            } else {
                print("Document successfully updated")
                self.showToast(message: message)
            }
        }
    }
content_copyCOPY