Search code examples
firebasegogoogle-cloud-platformgoogle-cloud-firestore

Firestore pricing related to collectionReferences


How many reads are counted for the following query?

fireClient.Collections(ctx).GetAll()

will the following query result in 1 read or will it depend on the number of subcollections?

fireclient.Collection("users").Doc("user_id").Collections(ctx).GetAll()

I am trying to list down the subcollections within a document. I want to know the pricing for the same?

Edit: Get All function - go docs


Solution

  • When you call GetAll() in this line:

    fireClient.Collections(ctx).GetAll()
    

    You will get all root collections and when you call GetAll() in this line:

    fireclient.Collection("users").Doc("user_id").Collections(ctx).GetAll()
    

    You'll get all sub-collections of the user_id document.

    In both situations, you'll get an array of collection references. This means that you only read the names of the collections and not the actual documents within them. So since you aren't reading any documents, there is nothing you should pay. That's the reason why you cannot find anything related to this in the pricing section.