简体   繁体   中英

Firestore - Can I get all documents ID just like collection list?

I know I can get all collections ID: List subcollections of a document

This method only billed one document read. (If I have 1.000 Subcollections and I read collections ID list, then I pay one document read.)

a request for a list of collection IDs, you are billed for one document read.

But I want to get all documents ID in collection. I don't want query every documents, I'm not interest what the document contains. I need only documents ID, and I want to pay only one document read. Can be solved?

I try:

          return db.collection('Testcollection')
.listDocuments().then(results => {
    
    results.forEach(collection => {
        console.log('Collection ID:', collection.id);
 }); 
return;  
});

This is working good, but I see usage in cloud and counts every document for billing.

So I need a solution where it lists IDs of all documents but only bills one. Do you have any idea?

Thanks!

This is not possible. You're asking for an API that Firestore doesn't offer. Any time any query finds a document, even if it's just getting the ID of the document, it costs 1 read per document found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM