'Can you set read rules in firestore depending on values in other doc in other collection?
In my app I have 4 collections echo collection has certain set of premium content .
my collections are Data , Weeks , Plans , Shared ... I am trying to block the reading of data from each collection using premium until attribute that I want to nest in the main collection with is data, and make (weeks , plans and shared) collections read and write privileges, connected to attributes found in Data which is securely triggered by a cloud function. instead of running cloud function 4 times and nest the the premium until in 4 collections.
The issue here is the architecture of my app I needed to spared the data in to multi collections. any idea how to do this. I saw a video about making rule that strict read depending on a JWT, but as for now I don't want to use JWTs.
Can I set the rules in each of the 3 side collection to checking if the premium until is valid in the main collection ?
// Read Allow read if the user is authoridzed and the premium time is valid
allow read : if request.auth != null && resource.data.premiumUntill < timestamp.Now()
// Read Allow read if the user is authoridzed and the premium time is valid
allow read : if request.auth != null
&& resource.data.premiumUntill (in data collection is valid ?)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
