[英]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?是否可以在 firebase 火库中的集合文档之间循环? I have a collection which contains multiple documents with random IDs, and I want to get all these documents and display them.我有一个包含多个具有随机 ID 的文档的集合,我想获取所有这些文档并显示它们。
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:我的意思是,如果我有 10 个文档,我想在它们之间循环并在页面上显示每个文档数据,就像我们使用for循环时一样:
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.如果有办法不使用for循环就可以了。
The Firebase documentation has a pretty good example of reading all documents from a collection . Firebase 文档有一个很好的示例, 可以从集合中读取所有文档。 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.确切的语法取决于您使用的 SDK 版本,因此我建议从那里的示例开始,然后根据您的需要调整它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.