Ad

How Can I Get Single Document From Firestore With Query (I'm Using Ionic 4 )

- 1 answer

Good morning , I have database in firestore below :

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

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

Ad

Answer

You can achieve this by querying specific document id:

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

For you the query will look like this:

firestore.collection('123').doc('news1').valueChanges()
.subscribe(news1=>{
console.log(news1)
});
Ad
source: stackoverflow.com
Ad