In this document of Cloud Foreshore it is mentioned that 'a request for a list of collection IDs, you are billed for one document read.'
Now I am using AngularFire and Ionic3 for my project. My requirement is to fetch just the collection IDs from a collection with a where condition. If I do the following, it will cost me the number of reads = number of docs in the result.
let snap = this.afs.collection('path').ref
.where('field', "==",'data').get();
snap.forEach(x => {
list.push(x.id);
});
I am not able to use method getCollections()
which I found in a few places as a solution.
Please let me know if you have a solution.
The Firestore getCollections()
method only exists in the server-side SDKs, where it is charged as a single read operation. But as Doug answered, it returns the collection ids/names, not the document ids.
To get the document IDs on the client, you will need to read the entire document. So this will be charged as the number of document you read, and will consume bandwidth for all data in each document.
On the server, you can use the select()
method to get a list of only the document IDs. You will still be charged for reading each of the documents, but it will consume less bandwidth.
See:
It sounds like you are wondering if there is a way to get all the document IDs in a collection without incurring a read for each document. This is currently not possible. When using Firestore client SDKs, your only option is to query the entire collection, which will transfer the entire contents of every document to the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With