代码之家  ›  专栏  ›  技术社区  ›  Judy Hopps

为什么我更新文档时文档会保留原始数据?它会立即返回到以前的状态。没有错误

  •  0
  • Judy Hopps  · 技术社区  · 1 年前

    我在Firestore数据库中收集了很多文档。我在React中编写了一个函数来更新文档的数据。

    try {
    
        await firebase.app
            .firestore()
            .collection("Records")
            .doc(recordId)
            .update({ public: value, _author: UserProfile.getEmail() });
               
        return {
            status: status.SUCCESS
        }
    
    } catch(error) {
        return {
            status: status.INTERNAL_SERVER_ERROR
        }
    }
    

    我以经过身份验证的用户身份更新文档,对于其他文档,更新功能正常工作。但它并不仅仅适用于少数唱片。

    我在Firebase的身份验证中检查了用户的权限。一切都在那里启用了。

    这是一个文档示例。 enter image description here

    1 回复  |  直到 1 年前
        1
  •  0
  •   Super Developer    1 年前

    我以前经历过这个问题。我确信这是一个许可问题。您可以在文档中添加“访问”字段。 “访问”字段包括“编辑”、“执行”、“所有者”、“读取”等。

    "Access": {
        "Exec": ["[email protected]"],
        "Owner": ["[email protected]"],
        ...
    }
    

    当我将用户的电子邮件添加到“所有者”数组中时,它起了作用。

    推荐文章