如何使用"get"方法检索angularFire2中的所有集合 [英] How to use "get" method to retrieve all collection in angularfire2

查看:31
本文介绍了如何使用"get"方法检索angularFire2中的所有集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase云存储提供了获取整个集合的方法,如下所示-

    db.collection("users").get().then((querySnapshot) => {
        querySnapshot.forEach((doc) => {
            console.log(doc);
        });
    });

我在Ionic 3项目中使用的是AngularFire2版本5.0.0rc3来连接Firebase云存储。

我正在尝试访问此GET方法,如下所示-

    constructor(
        private afs: AngularFirestore
    ) {
    
        this.afs.collection("users").get().then((querySnapshot) => {
            querySnapshot.forEach((doc) => {
                console.log(doc);
            });
        });
            
    }
但在这里,";get";方法不起作用。谁能告诉我谁应该将此"get"方法用于Firebase云存储和angularFire2。

FireStore

实际上可以用,只需调用FireStore this.afs.firestore.collection

即可
let userDoc = this.afs.firestore.collection(`users`);
userDoc.get().then((querySnapshot) => { 
   querySnapshot.forEach((doc) => {
        console.log(doc.id, "=>", doc.data());  
   })
})

这篇关于如何使用"get"方法检索angularFire2中的所有集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆