![](/img/trans.png)
[英]How to Get all Firestore Collections and Documents? | React JS
[英]How to get All documents from Firestore in React Native?
我一直在尝试多种解决方案来从 Firebase Firestore 获取所有文档。 我正在处理 iOS 部分,我什至在 iOS 项目中添加了 google plist 文件,但无法取回数据。 Firestore 说它被击中了多次,但当谈到结果时,我什么也没看到。
这是我正在使用的代码:
async function getAnnouncements() {
const usersCollection = await firestore().collection('Announcements').get();
console.log(usersCollection);
}
根据文档,它应该被称为 promise 而不仅仅是 function。
import firestore from '@react-native-firebase/firestore';
async function getAnnouncements() {
const usersCollection = await firestore().collection('Users').get()
.then((querySnapshot) => {
/*
A QuerySnapshot allows you to inspect the collection,
such as how many documents exist within it,
access to the documents within the collection,
any changes since the last query and more.
*/
querySnapshot.forEach((documentSnapshot) => {
console.log('elements: ', documentSnapshot);
});
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.