在firestore安全规则中,执行request.resource.data()是第一次写入吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.