Reputation: 9
So my firestore database is structured as such:
documents -> collection -> docID -> collections -> documents
Inside the docID document I have a field called live which is a boolean set to either true or false. If live is true, I want to allow access to all documents and subdocuments, but if its false do not allow read. I've tried structuring it as such:
match /collections/{docID} {
allow read: if resource.data.live == true;
allow write: if false;
}
What is incorrect with this code?
Upvotes: 0
Views: 394
Reputation: 301
match /collection/{docID} {
match /collections/{document=**} {
allow read: if get(/databases/$(database)/documents/collection/$(docID)).data.live == true;
allow write: if false;
}
}
Here, document=** means all nested documents (of the same collection as well as nested). And a simple get call to read your {docID} document.
You can find more info here Access other documents
Upvotes: 1