Learn Courses My Dashboard

How to set firebase rules

When we setup Firestore, we are given a default rule that essentially gives access to all documents in our DB to anyone who has access to our firebase instance, right?
I wanted to know how to write custom rules to allow only authenticated user to read which ever document is relevant to them.
For example:
• There are 2 users in my users collection – User_A and User_B.
• There are 10 documents in my Papers collection.

Q1. Now, how do I query from Firestore such that, I get Papers1,2,3,4 for User_A and papers7,8,9 for User_B. I know I want User_A to access only those documents that are relevant to him. Same case for User_B.

Q2. I am used to making GET requests in JS but how do we apply filters to queries in Firebase?
I just am unable to find a way out. Help would be appreciated.

i think it would be best to check official firebase documentation for this or firebase forums

Theres a great video on Firestore rules in the Firebase documentation. I dont have a link right now, but im sure you can find it :smiley: