【问题标题】:Firebase Python firestore.DELETE_FIELD appears as an error in VS CodeFirebase Python firestore.DELETE_FIELD 在 VS Code 中显示为错误
【发布时间】:2019-01-31 23:55:44
【问题描述】:

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

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

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

【问题讨论】:

    标签: python firebase google-cloud-firestore member


    【解决方案1】:

    如果其他人到达这里,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})
    

    【讨论】:

      猜你喜欢
      • 2018-07-15
      • 2023-01-20
      • 2020-10-20
      • 2022-08-23
      • 1970-01-01
      • 2018-02-14
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多