Firestore规则允许读取条件时间戳问题

问题描述 投票:0回答:1

我第一次使用firestore而且我遇到了问题,如果邮件发送的时间少于5分钟,我想允许读取但是它不起作用。

service cloud.firestore { match /databases/{database}/documents { match /locations/{allDocuments=**} { allow read: if request.time < Timestamp.fromMillis(resource.data.timestamp) + duration.time(0, 5, 0, 0) allow write: if true; } } }

每个数据都有一个子调用“timestamp”,值是一个像“1554710156002”的数字

有了这个读取条件,我的应用程序无法读取任何内容,但它可以写入有人知道问题是什么吗?

firebase google-cloud-firestore firebase-security-rules
1个回答
0
投票

尝试使用qazxsw poi(文档qazxsw poi)来操纵qazxsw poi:

duration.time(hours, minutes, seconds, nanos)

此外,我个人的偏好是在(固定的)资源创建时间之后设置持续时间,这使我对它的推理更容易一些。

你的代码会变成

here

(注意:我没有验证这一点,这假设你的时间戳实际上是一个timestamps

© www.soinside.com 2019 - 2024. All rights reserved.