简体   繁体   English

如何在 firebase firestore 中的集合文档之间循环?

[英]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.

相关问题 如何在 Firebase Cloud Firestore 中删除具有相同键值的集合中的文档 - How to delete documents in a collection with the same key value in Firebase Cloud Firestore 如何遍历 Firebase Firestore 文档数组并将值推送到数组中 - How to loop through an array of Firebase Firestore documents and push values into array 在Firebase Firestore中,如何在没有数据的情况下获取所有文档的ID? - How to get the id's for all documents without the data in a parsed collection in Firebase Firestore? 如何检索集合中的所有文档并查看 firebase Firestore 中是否存在文档? - How do to retrieve all documents in a collection and see if a document exists in firebase Firestore? 如何使用 react.js 中的 WHERE 查询计算 Firebase Firestore 中集合中的文档数 - How To Count Number of Documents in a Collection in Firebase Firestore With a WHERE query in react.js Firestore:如何通过存在于其他集合中来过滤文档? - Firestore: how to filter documents by existing in other collection? 如何在 Firestore 中“获取集合中的所有文档”? - How to "Get all documents in a collection" in Firestore? 如何删除firestore集合数据库中的所有文档 - How to delete all the documents in a firestore collection database 如何获取 firestore 集合中的所有文档? - How to get all documents in a collection in firestore? 从集合 firebase firestore 中的所有文档中获取数据 - get data from all documents in an collection firebase firestore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM