在firestore安全规则中,执行request.resource.data()是第一次写入吗?

发布于 2025-01-28 17:57:56 字数 565 浏览 5 评论 0原文

match /databases/{database}/documents 
  {
    match /users/{theuser=**}
    {
     match /prescriptions/{prescriptions}
      {
      allow read, write: if
     (request.resource.data.TheClinicianEmail == request.auth.token.email);
      }
}
} 

在此示例中,我正在检查文档“处方”字段。首次创建此文档时,请request.resource.data只是我传递的数据,因为还不存在文档吗?

await db.collection('users').doc(Theemail).collection('Prescription').add({
           
            TheClinicianEmail: Theemail,
        })

在这里,我添加字段 - > theclinicianemail,第一次创建文档时。

match /databases/{database}/documents 
  {
    match /users/{theuser=**}
    {
     match /prescriptions/{prescriptions}
      {
      allow read, write: if
     (request.resource.data.TheClinicianEmail == request.auth.token.email);
      }
}
} 

In this example, I am checking the field of "TheClinicianEmail" for the document 'prescription'. When creating this document for the first time, will request.resource.data just be the data that I pass in, since no document exists yet?

await db.collection('users').doc(Theemail).collection('Prescription').add({
           
            TheClinicianEmail: Theemail,
        })

Here I add the field -> TheClinicianEmail, when the document gets created for the first time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜尕妞 2025-02-04 17:57:56

request.resource.data始终客户端传递的数据(请求)。

resource.data是已经在Firestore中的数据(如果有)。

request.resource.data is always the data being passed up by the client (the request).

resource.data is the data that is already in Firestore, if any.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文