我正在使用Firebase存储一些用户数据。因此,现在我要删除检查“ last_ubdated”时间
我已经创建了规则,但是它不能正常工作。(下面的代码)
{ "rules": {
".read": true,".write": true,"$drivers":{
".indexOn": ["driverId"],".write": "newData.exists() || data.child('last_updated').val() > (now)",} } }
Firebase安全规则在添加后无法更改任何数据。它们仅在客户端读取或写入数据时生效。如果要安排按计划删除某些内容,则需要其他解决方案。
另请参阅:Cloud Functions for Firebase trigger on time?
,正如道格所说,安全规则不能更改数据。它们只会影响允许的(读和写)操作。
一种替代方法是使用查询仅请求尚未过期的节点,然后使用安全规则确保仅允许该查询。有关示例,请在这里查看我的答案:How to make data unreadable once the time indicated on its time stamp has passed?