简体   繁体   English

如何使用swift更新firebase firestore中的文档?

[英]How to update a document in firebase firestore using swift?

when i run the following code i get this error.当我运行以下代码时,我收到此错误。

['FIRESTORE INTERNAL ASSERTION FAILED: Invalid document reference. ['FIRESTORE 内部断言失败:文档参考无效。 Document references must have an even number of segments, but User has 1']文档引用必须有偶数个段,但用户有 1']

func saveLabel(uid: String, label: String){
  
    let userRef = db.collection("User").document(uid)
    
    userRef.updateData(["label": label]) { (error) in
        if error == nil {
            print("updated")
        }else{
            print("not updated")
        }
        
    }

}

This error almost certainly means that uid is empty.这个错误几乎肯定意味着uid为空。 You should log it to make sure.你应该记录它以确保。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 swift 在 Firebase Cloud Firestore 中获取文档的 position? - How do I get the position of a document in Firebase Cloud Firestore using swift? 如何使用 Firebase Firestore 在 Swift 中获取当前用户的文档 ID? - How to get current user's document id in Swift using Firebase Firestore? 如何从 swift 的 Firebase Firestore 中删除当前用户的特定文档? - How to delete specific document for the current user from Firebase Firestore in swift? 使用 Swift 中的文档 ID 数组更新多个 Firebase 文档 - Update multiple Firebase documents using an array of Document IDs in Swift 如何使用 swift 在 Firestore 文档的字段中生成 null 值? - how to make null value in a field in firestore document using swift? 如何使用Swift在iOS的Firebase Firestore中的文档中获取arrayList - How to get the arrayList inside documents in firebase firestore in ios using swift 如何使用 swift 更新 firebase 中的数据? - How to update data in the firebase using swift? 如何使用Swift在Firebase中更新令牌? - How to update token in firebase using swift? 获取在文档 Swift Firestore Firebase 中声明的所有 Collections - Get all Collections that are declared on document Swift Firestore Firebase Swift 和 ios 中 Firebase Firestore 文档的访问字段 14? - Access Fields of Firebase Firestore Document In Swift and ios 14?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM