Firebase - Firestore rules: throttle create requests

Viewed 604

Since I've found nothing online. I would like to know, if there is a firestore rule that allows create request for stories from a simple user only after every 60 sec?

My Data-structure is simple:

stories--
        |
        - document 1
        - document 2 
         ...
users--
       |
        - document 1
        - document 2
         ...

I basically have two top level collections. The documents of my Stories collection contains also a timestamp property. So on the rules for my stories collection, it should look like this:

service cloud.firestore {
  match /databases/{database}/documents { 
    match /stories/{storyId} {

      allow create: if isSignedIn() && isVerified() && throttleRequestTime();
    }
  }
}

function throttleRequestTime() {
    return request.time < ***the value to compare*** + duration.value(60, 's');
}
0 Answers
Related