我在 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的身份验证中检查了用户的权限。那里一切都已启用。
我以前也遇到过这个问题。我确信这是一个权限问题。您可以将“访问”字段添加到文档中。 “访问”字段由“编辑”、“执行”、“所有者”、“读取”等组成
"Access": {
"Exec": ["[email protected]],
"Owner": ["[email protected]],
...
}
当我将用户的电子邮件添加到“所有者”数组中时,它起作用了。