【问题标题】:Get Cloud Firestore database collection获取 Cloud Firestore 数据库集合
【发布时间】:2019-12-24 15:21:05
【问题描述】:

我正在尝试从我的数据库层次结构 db.collection/doc/collection/ 中获取数据

我需要从集合“产品”中获取数据

我已经可以通过使用这个 sn-p 过滤掉正确的文档。 尽管如此,还是没有设法从下一个集合中获取任何数据。

db.collection('deliveryservice').where('owner_id', '==', user.uid).collection('product').get().then((snapshot) => {
        snapshot.docs.forEach(doc => { 

【问题讨论】:

  • 我不明白你为什么使用where。何时可以使用doc 使用文档参考。

标签: javascript firebase web google-cloud-firestore


【解决方案1】:

请尝试以下方式从您的product 集合中检索数据。

var docRef = db.collection("deliveryservice").doc(user.uid).collection('product');

docRef.get().then((snapshot) => {
    snapshot.docs.forEach(doc => { 
    }
}).catch(function(error) {
    console.log("Error getting document:", error);
})

【讨论】:

    猜你喜欢
    • 2021-09-03
    • 2018-03-18
    • 2019-03-12
    • 2018-11-07
    • 2020-09-03
    • 2019-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多