允许根据文档中的时间戳值读取FireStore规则 [英] Allow read in FireStore rules based on timestamp value in document
问题描述
我想创建一个FireStore规则,该规则在当前日期超过文档中的时间戳记值之后向文档授予读取特权.
I want to create a FireStore rule that grantes read privilages to documents after the current date has surpassed a timestamp value in the document.
这是针对博客Web应用程序的. 例如,博客作者将博客文章设置为在特定日期对公众开放.
This is for a blog web application. E.G a blogger sets a blog post to be available to the public on a certain date.
通过阅读文档应该可以,但是不能.
From reading the documentation this should work, but It dosn't.
service cloud.firestore {
match /databases/{database}/documents {
match /Articles/{article}{
allow read: if request.time.date() < resource.data.date
}
}
}
我想念我什么?
推荐答案
firebaser此处
我前一阵子尝试过同样的事情,发现目前不可能.
I tried the same thing a while ago, and found out it isn't currently possible.
可以基于该文档的属性允许/拒绝对该文档的读取.
It is possible to allow/deny read to a specific document based on a property of that document.
可能允许查询基于该文档中的属性来过滤文档,但目前仅基于request.auth
才可能.
It is possible to allow a query that filters documents based on a property in that document, but currently that is only possible based on request.auth
.
这意味着很遗憾,您的过滤器当前无法使用安全规则来实施.我建议您提交功能请求.
This means that unfortunately your filter currently can't be implemented with security rules. I recommend you file a feature request to chime in.
更新(2018-04-24):request.time
这个 ,但是我还没有机会进行测试.在此处.
Update (2018-04-24): this might now be possible with request.time
, but I haven't had a chance to test yet. Have a look here.
这篇关于允许根据文档中的时间戳值读取FireStore规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!