首页 > 解决方案 > Firestore 中的 updateData() 函数存在问题

问题描述

这是我在 Firestore 数据库中更新字段的代码:

private var db = Firestore.firestore()

func moveToNextWeek(){
    let newWeekOn = plan!.weekOn + 1
    db.collection("Users").document(Auth.auth().currentUser!.uid).collection("Plan").document("plan").updateData(["weekOn": newWeekOn])
}

但是我不断收到错误:Ambiguous use of 'updateData'. 我不明白为什么这个错误不断出现,有什么想法吗?

标签: swiftfirebasegoogle-cloud-firestorecompiler-errors

解决方案


可以通过将其分配给变量并添加来修复它.description

let _ = db.collection("Users").document(Auth.auth().currentUser?.uid ?? "NO USER").collection("Plan").document("plan").updateData(["weekOn": newWeekOn]).description 但是,我不确定为什么会这样。


推荐阅读