Firestore listener data usage [duplicate] - firebase

This question already has answers here:
Does updating one field will download the whole document from the database or just update local version?
(1 answer)
Only retrieve changed document field
(1 answer)
Closed 2 years ago.
I have a question about the bandwidth / data usage of a Firestore listener.
I know Firestore will only give the updated documents once it's listening.
Let's say a single document is 0.3 mb. If it gets updated frequently, does the listener has to download the document (0.3 mb) every time or will it only download the "new/updated" data.
This would make a difference for the end-user who is maybe using 4g.
I use Flutter in combination with Firestore.
Thanks!

Every time a document is updated from an active listener, the entire contents of the document are transferred with each update. It does not transfer only the fields that changed.

Related

Retrieving a list of entires in Google Firebase's Firestore [duplicate]

This question already has answers here:
Firestore - get specific fields from document
(4 answers)
How to access a specific field from Cloud FireStore Firebase in Swift
(5 answers)
How to get a list of document IDs in a collection Cloud Firestore?
(4 answers)
Closed 1 year ago.
Suppose I wanted to use Google Firebase's Firestore as the backend of a simple website showing a list of (journal) entries, and the ability to view an entry, edit an entry, and delete an entry. Fundamentally, I would want to retrieve the list of entry titles, so I could present in my website a table of contents. Then when the visitor clicks one of the titles, the website would navigate to the entry's content.
Now, my question is, how do I get just the titles without the content, of the entries? As far as I have read, this is not possible. I present this problem here to confirm whether I have missed something, or if it is indeed impossible with Firebase to get some of the data from a collection of records, without having to retrieve all of the data.
how do I get just the titles without the content, of the entries?
As you've already found, the client-side SDKs for Firestore always retrieve full documents. The server-side SDKs and REST API have a projection/selection mechanism to retrieve only a subset of the fields, but that ability does not exist in the client-side SDKs.

Does firestore save the change history on the documents? [duplicate]

This question already has answers here:
Firestore: Version history of documents
(3 answers)
Firebase Firestore Documents changes history (like Activity log/ History for changes in each Doc)
(3 answers)
Closed 1 year ago.
I had an issue, where I accidentally deleted some data saved on a property of a document of FireStore, and I'm trying to get back the data.
If FireStore saves the change history, it would be easy to retrieve the data, but I don't see if they do.
Thanks
Firestore does not store any sort of change history, you can create this behavior yourself using Cloud Functions with an Update trigger
The only downside is that Cloud Functions does require a Billing account attached and the project upgraded to Blaze Plan.
if that is not an option for you, you will have to create new documents for each revision made to the previous document and update the relative paths to the latest document

Firestore billing on update [duplicate]

This question already has an answer here:
Firestore billing for writes that have no effect [duplicate]
(1 answer)
Closed 2 years ago.
If I update a document with the same content as the existing one, will it count as a write even if it doesn't change anything to the current document's content?
In other words, does Firestore update the document without checking the values of each key inside the document?
If I update a document with the same content as the existing one, will it count as a write even if it doesn't change anything to the current document's content?
Yes, it does.
In other words, does Firestore update the document without checking the values of each key inside the document?
Yes, it does update, it overwrites the entire document, no matter if is the same or not. Firestore doesn't have a mechanism to check if the document is the same. You should check that out.

Firestore billing for writes that have no effect [duplicate]

This question already has answers here:
Document Updates - Do updates with no changes still cost 1 write?
(2 answers)
Closed 2 years ago.
Im trying to find out how firebase is billing write operations. In the billings documentation I could not find a clear definition of when a write is counted. Lets say I run a set query with the exact same data of the original documen, such that the document won't be affected, will this be billed as a write operation?
When I run my query with the console open nothing happens, and i was just wondering if these writes do also count.
When you write data, the server doesn't check if the data you write is the same as what already exist. Instead: it writes the data you provide. Hence: writing the same data is still counted as a write operation.
I find it easiest to understand the billing for Firestore by thinking of it as reads from/writes to a disk. When you tell a disk to write a file, it writes that file.

Firestore security rules to count documents [duplicate]

This question already has answers here:
How do you force a Firestore client app to maintain a correct document count for a collection?
(2 answers)
Closed 3 years ago.
I need to limit the number of documents a user can have in a collection.
I expect that having a limit of let's say 100 documents when a user tries to create the document 101 gets an error.
Is there a way of doing this using firestore security rules ?
Security rules don't have the capability to count the number of documents in a collection. In fact, counting documents in Firestore is, in general, is kind of a difficult problem that typically requires some support from a product like Cloud Functions.
If you want to get something like this to work, you will have to write some Firestore triggers in Cloud Functions that manages the count of documents by triggering some code when a document is created or deleted. This count would have to be stored in another document in another collection. Then, the contents of that document could be used in security rules to limit client access.

Resources