// https://angularfirebase.com/lessons/firestore-security-rules-guide/
// https://medium.com/@jek.bao.choo/my-firestore-security-rules-learning-notes-14316400f160
Scope Rules to Specific Operations Rules can be enforced on various read/write operations that occur in a clientside app. We can scope rules to each of the follow read operations.
allow read - Applies to both lists and documents. allow get - When reading a single document. allow list - When querying a collection. Write operations can be scoped as follows:
allow create - When setting new data with docRef.set() or collectionRef.add() allow update - When updating data with docRef.update() or set() allow delete - When deleting data with docRef.delete() allow write - Applies rule to create, update, and delete. Request vs Resource Firestore gives us access to several special variables that can be used to compose rules.
request contains incoming data (including auth and time) resource existing data that is being requested This part is confusing because a resource also exists on the request to represent the incoming data on write operations. I like to use use helper functions to make this code a bit more readable.