python - Firebase Python firestore.DELETE_FIELD 在 VS Code 中显示为错误

标签 python firebase google-cloud-firestore member

所以我在我的 Firestore 数据库中的文档上使用删除字段方法,它似乎工作正常,但由于某种原因在 VS Code 中它显示为错误。我的设置与他们在引用文档中的设置几乎相同,只是我从变量中动态删除字段。这是我的代码的样子:

db.collection("collection1").document(doc1).update({fieldValue: firestore.DELETE_FIELD})

不知道为什么,但 VS Code 说 firebase_admin.firestore 没有“DELETE_FIELD”成员,但代码仍然按预期工作?没什么大不了的,但是我的编辑器显示我有错误但它仍然有效,这很烦人。让我知道你们是否遇到过这个问题。

最佳答案

万一其他人到达这里,DELETE_FIELD 是 google.cloud.firestore_v1.transforms 的一个属性

所以我解决了这个问题:

from google.cloud.firestore_v1.transforms import DELETE_FIELD
db.collection("collection1").document(doc1).update({fieldValue: DELETE_FIELD})

关于python - Firebase Python firestore.DELETE_FIELD 在 VS Code 中显示为错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52022458/

相关文章:

python - 如何重新定义我在 python 中导入的函数使用的函数?

python - 如何以常规范式打印日期?

ios - Swift - Firebase - 身份验证电子邮件无密码

java - Firestore中一步调用add时如何获取id?

javascript - Firebase 云函数 onCreate 更新数据库的速度非常慢

angular - 如何获取 firestore 时间戳

python - 按行值过滤 pandas 数据框时出现问题?

python - Matlab 用 For 循环连接行向量

javascript - 使用firebase(React)将用户数据添加到数据库(Google身份验证)

java - 使用唯一 ID 从 firebase 检索数据