允许根据文档中的时间戳值读取 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.
这是一个博客网络应用程序.例如,博主将博文设置为在特定日期向公众开放.
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 here
我不久前尝试过同样的事情,但发现目前无法实现.
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屋!