[英]Firestore get roots field of a document
From what you mentioned in your last comment, you can traverse a document as you would any other Map
or dictionary object.根据您在上一条评论中提到的内容,您可以像遍历任何其他
Map
或字典 object 一样遍历文档。 The Firestore documentation for Getting documents is a good place to start. 获取文档的 Firestore 文档是一个很好的起点。 As for your nested field, if you would like to get the
Title
value, you could do it this way, by traversing the dictionary into the points
array, then traversing the nested dictionary to the Title
value:至于您的嵌套字段,如果您想获取
Title
值,您可以这样做,通过将字典遍历到points
数组中,然后将嵌套字典遍历到Title
值:
const docRef = doc(firestoreDB, "innerArray", "testDoc1");
const getData = async () => {
const docSnap = await getDoc(docRef);
console.log(docSnap.data().points[0].title) //traversing the data obtained from a document
}
This outputs foo
, which is the value for Title
in my test document.这将输出
foo
,这是我的测试文档中Title
的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.