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

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

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.

Firestore listener data usage [duplicate]

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.

Firestore Documents Template [duplicate]

This question already has answers here:
Firebase Firestore: Is there a way to enforce required fields for all documents in a collection?
(3 answers)
Closed 2 years ago.
I'm creating a Firestore Database that has a "devices" collection then each device has its own document. I already have a device with various fields.
Is there any way I can create a template where the document fields remains the same for all documents and I can just fill in the values upon adding a new device from the Firebase console?
Documents in Firestore only contain exactly what you put in there. There are no "default" or "understood" fields. If you want a document field to contain some value, you will have to write it into each document.

How to create a firebase cloud function that could trigger when database is read [duplicate]

This question already has an answer here:
how to trigger firebase cloud function on read event
(1 answer)
Closed 3 years ago.
Is it possible to have a firebase cloud function that could trigger when sone one read the realtime database.
As per this document https://firebase.google.com/docs/functions/database-events , We can have cloud function to trigger when data is created, updated, or deleted on Realtime Database. But i want to do some external network call if some one is reading the data.
Right now there is no OnRead trigger or a way to achieve this behavior, however Here is a feature request on Google to support this in the future.
I recommend you to follow up over there to see any progress made on this.

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