2017-10-07 104 views
1

在Firestore安全设置中,您可以设置写入/读取数据的条件。Firestore每次写入访问限制

目前我有这片:

service cloud.firestore { 
    match /databases/{database}/documents { 
    match /{document=**} { 
     allow read: if request.auth != null && request.time < 
       resource.data.timeCreated + duration.value(1, 'h'); 
     allow write: if request.auth != null; 
    } 
    } 
} 

现在我要限制的写作;用户应该只能每5分钟发送一次数据。我怎样才能做到这一点?

回答

0

有没有一种原生的方式来做到这一点。

你不能以任何不平凡的方式绕过非登录用户。尽管您可以使用云功能为登录用户实现此功能。

每个用户在下次可以写入时都有一个配置文件,以及下一个要写入的文档的id。

  • 使用规则上写检查该ID不存在,它是> =允许的时间
  • 使用云功能上写更新与新的允许的时间和唯一ID为用户配置文件下一次写
+0

我该怎么做? (对不起,但对我来说非常困难) –