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.
Related
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.
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
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.
This question already has answers here:
How to get a list of document IDs in a collection Cloud Firestore?
(4 answers)
Closed 5 years ago.
Is it possible to get only documents name as a String array without retrieving any collections? I couldn't find any documentation about it.
There is no API to retrieve only the document names in the SDKs. But the REST API has a list call that seems to do precisely that.
This question already has answers here:
Firestore query documents with only collections inside
(2 answers)
Closed 5 years ago.
Is there any naming convention for document id in FireStore. I created some documents inside a collection with the date in "yyyy-mm-dd" as the id. When i try to get all documents inside the collection i got the snapshot size as zero. When I put a dummy doc with test as id I got only the test doc not the other docs.
My document structure
The contraints can be seen here Quotas and Limits if you scroll down to the bottom you will find contraints on ids, paths and field names.