Hows does firebase firestore read counted? - firebase

Please someone help me to know how does the firebase firestore read counted.
I noticed that whenever i view my data in firebase console that too taken as in "read" so my doubt is whether i would be charged when my client view the fetched data in the app too! initially i thought that
i would be charged only for the "read" done by the user in my app. I know that 1 document is equal to one read, but i never knew that read is also counted when we actually see the data in the firebase console.
so please help me to know the right way to use it, this is creating a headache for me. and thanks in advance

You're charged for reads in the console too. Generally, this number is low during the development phase and should easily be covered by the free trial.
If your documents are excessive, you may prefer building a separate admin dashboard for him/her. Using
If you are charged heavily just for opening the firestore console, you may consider creating a blank collection with the name a - so that whenever you load firestore console, only documents in the a collection are loaded.

One Firestore document read is counted (and charged if you have reached the free quota limit of 50K/day for reads) in both cases: the document is read from the Firebase Console or the document is read from your app.
help me to know the right way to use it
There is no real "right way". You are charged one document read each time you read a Firestore doc (whatever is the way of reading it) and you have reached the free quota limit (i.e. 50K/day for reads)
You will find more details in the dedicated Firestore doc.

Related

Firebase Data Loss? [duplicate]

I really like the offering that's Cloud Firestore. But does it have an audit trail?
Why am I asking? While some use of databases is essentially "state" (e.g. multiplayer games), for other uses also the history matters. Also, at times being able to see the history would be useful for debugging purposes (time travel).
So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?
Do people use additional commentary documents to do this at the application level, or can I just enable a setting somewhere that would create such a document behind the scene, automatically? (I could then describe access rights just as for any other Firestore document.)
Addons, plugins etc. can also be suggested. I don't have a pressing use case for this right now - just want to understand where Cloud Firestore would fit and where not.
Btw, the Getting to know Cloud Firestore series in Youtube is plain awesome! :)
Edit: 2022-10-25
As Frank mentioned in his answer, yes, by the time I have written this answer, there wasn't a solution for audit logging. However, when it comes to today, this option is available and it can be also configured based on what you need.
For a better understanding, I recommend you check the official documentation regarding Firestore audit logging where it is said that:
Google Cloud services write audit logs to help you answer the questions, "Who did what, where, and when?" within your Google Cloud resources.
Old answer:
> **Note:** This answer was correct at the time of writing, but is now outdated. See [this answer](https://stackoverflow.com/a/74154622/209103) for details.
So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?
Cloud Firestore doesn't store such metadata. If you find yourself in a position in which you need such details, you'll need to create a mechanism to store them. So in case you want to know who deleted a specific value, you should create an array of objects where you should store the UID of the user who deleted that value and a timestamp.
Do people use additional commentary documents to do this at the application level
Yes, we usually do.
or can I just enable a setting somewhere that would create such a document behind the scene, automatically?
There is no such setting that can be enabled.
If you need a history version of the document, a possible schema that might help you is in my answer from the following post:
Firestore: Version history of documents
While Alex's answer was correct at the time of writing, Firestore nowadays provides audit logging capabilities that you can enable and configure based on your needs.
See the documentation on Firestore audit logging for full details on the Admin Activity audit logs and Data Access audit logs that can be set up.

What is the Concurrent Users Limit for Cloud Firestore Spark Plan?

i've been searching for what is the concurrent users limit for the cloud firestore spark plan but couldn't find it.
https://firebase.google.com/docs/firestore/quotas
It did said 1.000.000 concurrent users limit, but did not mention whether it is for the spark plan or the blaze plan. I've also tried searching answer elswhere, but did not find it answered specifically (with a source).
Help would be appreciated, thank you.
Per the Cloud Firestore pricing information (which Firebase uses):
When you use Firestore, you are charged for the following:
The number of documents you read, write, and delete.
The amount of storage that your database uses, including overhead for metadata and indexes.
The amount of network bandwidth that you use.
There is also no mention of any connection limits on Firebase's pricing page or the quotas documentation that you linked.
Unlike the Realtime Database, Cloud Firestore does not charge on a per-connection basis.
This video series also covers the ins and outs of Firebase products and is well worth sitting through.
Think of Cloud Firestore like a folder on your computer, which can contain thousands of little text files, similar to how documents in Cloud Firestore are stored. Users can update them with little chance of collision and grabbing a single document file would only require feeding 1s and 0s back to the requestor. This is why you are charged for network bandwidth rather than by individual connection.
In comparison, the RTDB was similar to one large JSON text file, with many people all trying to update it at once. Because parsing this text file on the server side was required to read and write data from it, it required compute resources to be able to do so. For this reason (among others), the number of connections the RTDB manager processes handled on behalf of spark plans were rate-limited to prevent abuse.

Does Firestore read all documents on page load even if they havent changed?

I am developing a chrome extension for the new tab page and I am trying to find the right DB for the project. The only question that is keeping me from using Firebase Firestore is to know how the DB handles reads.
Basically, every time the user opens a new tab page I will need to fetch around 3000 (very small) documents (hopefully from cache). My issue is that since opening a new tab page is done so frequently I will be charged an absurd amount of reads because firestore is always reading 3K documents.
My question is, is Firestore smart enough to tell that in the DB data has not changed and the client should only read from the cache?
I read all about offline persistence but this question is still lingering!
Thank you for any help!
When you start a listener you read first from the cache and then from the server. The cache persistance here explains how it behaves but considering only that the listener is in the listening mode. Even then after a 30 in offline you would be charged for a full read.
I would recommend you to read this. To manage your cache on your own to awoid to much reads as you are reading a large amount of data.

Does Cloud Firestore have an audit trail?

I really like the offering that's Cloud Firestore. But does it have an audit trail?
Why am I asking? While some use of databases is essentially "state" (e.g. multiplayer games), for other uses also the history matters. Also, at times being able to see the history would be useful for debugging purposes (time travel).
So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?
Do people use additional commentary documents to do this at the application level, or can I just enable a setting somewhere that would create such a document behind the scene, automatically? (I could then describe access rights just as for any other Firestore document.)
Addons, plugins etc. can also be suggested. I don't have a pressing use case for this right now - just want to understand where Cloud Firestore would fit and where not.
Btw, the Getting to know Cloud Firestore series in Youtube is plain awesome! :)
Edit: 2022-10-25
As Frank mentioned in his answer, yes, by the time I have written this answer, there wasn't a solution for audit logging. However, when it comes to today, this option is available and it can be also configured based on what you need.
For a better understanding, I recommend you check the official documentation regarding Firestore audit logging where it is said that:
Google Cloud services write audit logs to help you answer the questions, "Who did what, where, and when?" within your Google Cloud resources.
Old answer:
> **Note:** This answer was correct at the time of writing, but is now outdated. See [this answer](https://stackoverflow.com/a/74154622/209103) for details.
So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?
Cloud Firestore doesn't store such metadata. If you find yourself in a position in which you need such details, you'll need to create a mechanism to store them. So in case you want to know who deleted a specific value, you should create an array of objects where you should store the UID of the user who deleted that value and a timestamp.
Do people use additional commentary documents to do this at the application level
Yes, we usually do.
or can I just enable a setting somewhere that would create such a document behind the scene, automatically?
There is no such setting that can be enabled.
If you need a history version of the document, a possible schema that might help you is in my answer from the following post:
Firestore: Version history of documents
While Alex's answer was correct at the time of writing, Firestore nowadays provides audit logging capabilities that you can enable and configure based on your needs.
See the documentation on Firestore audit logging for full details on the Admin Activity audit logs and Data Access audit logs that can be set up.

Firebase storage states full after deleting all files

Like many other people out there, I am using Firebase for my project. In the past few days I have used Firebase quite a lot for sending media files between users. Now, I am also on the free plan, as I am still testing Firebase.
All of a sudden, Firebase has stopped responding, mentioning that
"You have exceeded your quota for this project. Please upgrade your plan.
LEARN MORE"
I know that Firebase has a limit on the amount of data I can transfer per day and store, that's no problem. My problem is that even after a full day, and having everything in storage deleted, I still get the same error.
Truth is, this error only shows up for the storage section. But, as you can see in the picture, my storage is now empty. Therefore my question is how can I reset firebase, or there's no other way around other than paying?
Since I am not able to see any files, I am also suspecting that I have not deleted them all, or them correctly? Could this be what's going on?
The more interesting part is the when clicking on "LEARN MORE", I am prompted to the following page, which is even more misleading.
Update: After looking at my quota details I found out that my Cloud Storage Network is full:
Looking at the Pricing for Storage on the Spark Plan it says that you can store up to 5Gb of data. Now this plan is based on Cloud Platform's Always Free and their documentation says "5Gb-months". I'm not sure of what that means, but I'm assuming that you have already exceeded your 5Gb for this month (even though you deleted the files afterwards). Maybe your quota will actually have some kind of "refresh" next month so you'll probably only be able to use Firebase storage again by that time.

Resources