简体   繁体   中英

How to loop between documents of a collection in firebase firestore?

Is it possible to loop between documents of a collection in the firebase firestore? I have a collection which contains multiple documents with random IDs, and I want to get all these documents and display them.

What I mean is that if I had 10 documents, I want to loop between them and show each document data on the page, like when we use the for loop:

let i;

for (i = 0; i < doc /* 10 */; i++) {
    document.body.innerHTML += // document data
}

It will be fine if there is a way to make it without using the for loop.

The Firebase documentation has a pretty good example of reading all documents from a collection . The exact syntax depends on the SDK version you use, so I recommend starting with the examples there and then tuning them to your needs.

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