Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从firestore获取采集数据_Javascript_React Native_Google Cloud Firestore_React Native Firebase - Fatal编程技术网

Javascript 如何从firestore获取采集数据

Javascript 如何从firestore获取采集数据,javascript,react-native,google-cloud-firestore,react-native-firebase,Javascript,React Native,Google Cloud Firestore,React Native Firebase,我正在使用firestore 我有健康名字收藏 collection health doc customername collection customerinfo // multiple doc customerwardinfo 代码: 我正在使用上面的代码,但没有得到数据。我想为每个子集合使用。但我无法实施它。我将如何获取所有数据。假设一个集合有10个文档。然后对每个文档使用foreach并从每个文档中获取数据。.doc().get()不返回文档的承诺;它返回DocumentSnapsh

我正在使用firestore

我有健康名字收藏

collection health
doc customername
collection customerinfo  // multiple
doc customerwardinfo
代码:

我正在使用上面的代码,但没有得到数据。我想为每个子集合使用。但我无法实施它。我将如何获取所有数据。假设一个集合有10个文档。然后对每个文档使用foreach并从每个文档中获取数据。

.doc().get()不返回文档的承诺;它返回DocumentSnapshot的承诺,其中包含的内容远远不止文档。

如您所见,DocumentSnapshot具有属性“exists”、“metadata”、“id”和“ref”,以及方法“data()”[返回带有文档字段的对象-数据],“get()”[可以从文档返回指定字段],“isEqual()”,可以比较DocumentSnapshot

on.doc().get().get()-虽然最终结果将仅为请求的字段,但整个文档将从数据库/存储中获取

正如Frank van Puffelen提到的,没有办法检索子集合列表-Firestore不强制执行或记录您的模式;这是你作为开发者的工作


Tracy Hall

如果您询问如何获取特定文档的所有子集合的列表,则客户端SDK不可能这样做。看见
firebase.firestore()
        .collection("health")
        .doc('customername')
        .get()
        .then((data)=>{            
            console.log("customer data",data);
        })