Flutter 这就是在Flatter中迭代Firestore集合上的文档的方法吗?
在下面的代码中,我试图使用flift和dart检索firestore中集合中的所有文档。这是最好的方法吗Flutter 这就是在Flatter中迭代Firestore集合上的文档的方法吗?,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,在下面的代码中,我试图使用flift和dart检索firestore中集合中的所有文档。这是最好的方法吗 Query () async { QuerySnapshot snapshot = await Firestore.instance.collection("collectionName").getDocuments(); snapshot.documents.forEach((document){ if(document.exists){
Query () async {
QuerySnapshot snapshot = await Firestore.instance.collection("collectionName").getDocuments();
snapshot.documents.forEach((document){
if(document.exists){
print('Documents exist');
}
else {
print('document does not exist');
}
});
是的,这是从集合中检索文档的方法。此外,默认情况下firestore将尝试脱机缓存数据并从那里加载数据,这有时会阻止firestore从服务器获取数据,即使服务器具有不同的数据。为了防止这种情况,您可以在getDocuments方法中添加源标志,
.getDocuments(源代码:source.server)代码>像这样。如果您想以不同的方式构建应用程序,那么您可以这样做,但是,您仍然需要调用相同的方法从firestore检索数据是的,这是从集合检索文档的方法。此外,默认情况下firestore将尝试脱机缓存数据并从那里加载数据,这有时会阻止firestore从服务器获取数据,即使服务器具有不同的数据。为了防止这种情况,您可以在getDocuments方法中添加源标志,.getDocuments(源代码:source.server)代码>像这样。如果您想以不同的方式构建应用程序,那么您可以这样做,但是,您仍然需要调用相同的方法从firestore检索数据“最佳”标准是什么?你有别的选择吗?你能做任何比较吗?不能和任何人比较。我只是问@DougStevenson“最佳”的标准是什么?你有别的选择吗?你能做任何比较吗?不能和任何人比较。我只是问“道格·史蒂文森”