Tracking your Firebase hosting bandwidth, & Firestore reference fields #AskFirebase

Firebase · 23K views · 2019 · 8:43

Open on YouTube

Databases & storageWeb developmentSoftware (other)explainerdated

Why Stack Overflow recommends it

Stack Overflow users link it when explaining that Firestore Reference fields offer little over plain string paths beyond console UI benefits.

Recommended by 3 people across 5 different months, 2019 to 2021.

What it is

An episode of Google's #AskFirebase series where Jen Person and Abe Haskins answer viewer questions. The second half (from about 4:34) explains what Firestore reference fields are for and how they behave compared with storing a path as a string; the first half covers tracking Firebase Hosting bandwidth with Stackdriver.

What people said

Recommends Renaud Tarnec · 2019-01 · Stack Overflow · on “Firestore references create a "TypeError: Converting circular structure to JSON"”

To answer to your second question about storing References: actually, at the time of writing this answer , there is no real advantage of storing References (i.e. path elements) as Reference [LINK] type instead of storing them as String. Please watch this official video from Firebase [this video] which contains detailed explanations (starting at 4:34).

Recommends Renaud Tarnec · 2019-08 · Stack Overflow · on “How to get document with reference fields populated”

@NodirNasirov "what is the point of having reference then?" -> You might be interesting by watching this episode of #AskFirebase (starting at 272 seconds): [this video]

Recommends Renaud Tarnec · 2020-03 · Stack Overflow · on “Firebase storage add file reference to firestore”

@LanFeusT "what is the Reference type in the console for". The Reference type is indeed a "strange beast"... you will find more details in this #AskFirebase video: [this video]

Recommends DIGI Byte · 2021-05 · Stack Overflow · on “Firebase array of references”

In firestore, a Reference object is constructed into a document or collection reference and you can invoke any of the document methods on it as needed. const ref = snapshot.data().reviews[0]; ref.get(); ref.remove(); The error in particular is saying that the item is not a string, which if it is a firestore reference, is an object and thus, not compatible. A great video to watch: [this video]

Recommends Ahmad Khan · 2021-11 · Stack Overflow · on “Cloud Firestore: Write document reference from Flutter Plugin/SDK”

Yeah, you can add a document reference in a document but it is not preferred in the development environment. You may use this on the Firestore console only. This episode [this video] from #AskFirebase might help you understand it properly.

Cites Renaud Tarnec · 2019-03 · Stack Overflow · on “Hot to build Firebase Chat Room database?”

At the time of writing, using a string or a Reference will not make a big difference from a developer perspective. According to this official Firebase video, at the time of writing , the Reference data type mainly "provides value in the Firebase console UI". You may watch the video starting at 4:37 for more detailed information: [this video] With both of these data types (Text string and Reference) you can "point" to a document and read the corresponding data, mimicking a primary key-foreign key relationship in SQL. For example, as explained in the documentation ( [LINK] ) you can create a DocumentReference [LINK] from a slash-separated path, like firebase.firestore().doc('/User/user_1') using th

Cites buryo · 2020-02 · Stack Overflow · on “Querying by a field with type 'reference' in Firestore”

At the moment, using `reference` as type is almost useless. Only thing it adds to you is that you don't make mistakes like referencing a document that doesn't exist. They have talked about this on their Google Channel: [this video]

Cites Lluís Muñoz · 2021-07 · Stack Overflow · on “Reference last document in a Firestore Collection”

Having a field referencing the last field of a collection, and automatically updating that reference so it always points to the last field, is not possible in Firestore. I would recommend just making a query to get the last document reference whenever you need it. But if you want to do it, as a workaround, you can update the field yourself, and there are a couple of ways to do it: Updating it from your code every time you add a new field to the collection you want to reference with an update query. Creating a Cloud Function using the onCreate or onWrite triggers to update the reference field each time changes are made to the collection. Please note that this approach, although the most relia