0

I was wondering if accessing data, For example view any item, modify any item in Db/Firestore directly via Firebase console adds to usage (data download/ FireStore Read etc.) I googled it to find an answer but I didn't find any. So raising my query here.

Also wanted to know if there is a way to provide write access to a particular child to 3-4 specific emails (google authentication). I understand we can allow writing to users who created it using the below rules. But in my case, I want others (few) also to be able to write to the child but not all( so cannot use ".write": "auth != null" )

{
  "rules": {
    "users": {
      "$uid": {
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Thanks in advance.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
tanni tanna
  • 544
  • 4
  • 12

1 Answers1

1

Yes, it does charge you. The documentation says,

Firebase console data: Although this isn't usually a significant portion of Realtime Database costs, Firebase charges for data that you read and write from the Firebase console.

Similarly you are charged for any reads and writes from the Firestore console. Also you need to be the project owner (or have editor/viewer role) to access the console. You'll be charged the amount of data loaded or written. For example, if the console loads 500 documents then you'll be charged 500 reads.

For the data retrieved from client side, "Firebase charges for the downloaded data. Typically, this makes up the bulk of your bandwidth costs, but it isn't the only factor in your bill." Make sure you check all the factors in the documentation above.

To allow specific users to read or write to your database, you can try using custom claims. You can refer to this answer for a detailed explanation on security rules with custom claims.

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
  • Any idea about the other query on providing access to certain users (email )? – tanni tanna Jul 12 '21 at 05:15
  • @tannitanna using client SDK, if you take a look at the documentation I shared above, it says "When clients get data from your database, Firebase charges for the downloaded data.". There are other factors as well such as SSL overhead. [Here's](https://firebase.google.com/docs/firestore/pricing) the documentation for Firestore billing. – Dharmaraj Jul 12 '21 at 05:17
  • @tannitanna you can add team members to your projects from project settings to give them editor role so they can edit it. You can refer to this [article](https://support.google.com/firebase/answer/7000272?hl=en) for detailed information. If you want to allow specific users to access data but don't want them to add in team, then try [Custom claims](https://firebase.google.com/docs/auth/admin/custom-claims). These are like roles which only you can assign using the Admin SDK. You can check if a user has custom claim in security rules. – Dharmaraj Jul 12 '21 at 05:19
  • You can refer to this [answer](https://stackoverflow.com/questions/68327600/firebase-custom-claims-without-cloud-functions/68327673) on adding custom claims. – Dharmaraj Jul 12 '21 at 05:34
  • Thanks. In my case I cannot use role options. I think Custom claims should be the option. My case is say there are students of class 1-10. Each class will have 3-4 students that can add data into Firebase. There will be nodes like Class A, Class B and so on. Only those 3-4 selected students from Class 1 can add/update items in nodes Class A. They shouldn't have write privilege's to any other class nodes. – tanni tanna Jul 12 '21 at 05:45
  • @tannitanna I don't know what your database structure looks like. But this is easy. You would have to add custom claims like `{class: "1A", moderator: true}`. Now your db must be structured in a way that you can easily verify these claims like separate node for each class. – Dharmaraj Jul 12 '21 at 05:48