所以我在我的 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/