Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Firestore – Am I charged for documents obtained without finishing reading their data?

Imagine you perform a query and retrieve 1000 docs from the database.

const querySnapshot = await query.get();

If I do not execute the .data() method of each doc to read their data, would it still be treated as 1000 reads?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, the get() retrieves documents from Firestore and you’ll be charged N reads where N is number of documents returned by your query. The .data() just returns the document’s data in JSON format from the snapshots.

Do note that, just creating the query neither retrieves the data nor charges you anything.

// This is just a Query
const query = db.collection('').where(...); 


// QuerySnapshot - contains the documents matching your query.
// fetches from Firestore (unless you have any offline persistence)
const querySnapshot = await query.get();


// Array of objects - parsed from the querySnapshot
const data = querySnapshot.docs.map((d) => d.data())
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading