繁体   English   中英

如何从Firestore而不是对象取回整个阵列?

[英]How to get the entire array back back from Firestore and not an object?

如何从Firestore而不是对象取回整个阵列?

我得到这个对象

https://i.stack.imgur.com/zphE1.png

相反,我想要一个数组

在此处输入图片说明

从我的firestore阵列中

https://i.stack.imgur.com/FjqvQ.png

到目前为止,这是我的代码。

fb.usersCollection
    .doc(this.currentUser.uid)
    .collection('fragebogen')
    .doc('fragebogen1')
    .get()
    .then(snapshot => {
      const data = snapshot.data()
      console.log(data)
    })
    .catch(error => {
      console.log(error)
    })

snapshot.data()返回一个对象,其中包含整个文档的内容。 对象的键是文档中字段的名称。 因此,如果该文档中的数组字段名为arr ,则您的数组将位于snapshot.data().arr

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM