如何通过查询从Firestore获取单个文档(我正在使用Ionic 4) [英] How can i get single document from Firestore with query (I'm using Ionic 4 )

查看:72
本文介绍了如何通过查询从Firestore获取单个文档(我正在使用Ionic 4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,我在下面的Firestore中有数据库:

Good morning , I have database in firestore below :

**collections**       **documents**     **fields** 
123                     news1           title:{some data}
                        news2           content:{some data}

例如,我想在ionc4应用程序的页面中获取(news1)的所有数据,我该怎么办?请帮帮我

for example i want to get the all data of the (news1) in the page of my ionc4 app , how can i do that please help me

推荐答案

您可以通过查询特定的文档ID来实现:

You can achieve this by querying specific document id:

firestore.collection(collectionName).doc(documentId).valueChanges()
.subscribe(singleDoc =>{
console.log(singleDoc)
});

对您来说查询如下:

firestore.collection('123').doc('news1').valueChanges()
.subscribe(news1=>{
console.log(news1)
});

这篇关于如何通过查询从Firestore获取单个文档(我正在使用Ionic 4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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