0

My database structure looks like this:

Enter image description here

I have to take all dNames and print it.

const db = firebase.firestore();

db.collection('map-data').doc('driver').get().then((snapshot) => {
  snapshot.docs.forEach(doc=> { console.log(doc.data()['dName']) })
});
  • Please share the code that you have tried. – Dharmaraj Jul 02 '21 at 07:27
  • tried this const db =firebase.firestore(); db.collection('map-data').doc('driver').get().then((snapshot)=>{ snapshot.docs.forEach(doc=>{ console.log(doc.data()['dName']); // console.log(doc); }) }); – Omkar Desai Jul 02 '21 at 07:31
  • What do you mean by *"take all list of dNames"* (seems incomprehensible)? – Peter Mortensen Jul 02 '21 at 07:38
  • i apologise for that. I have to take all dNames and put in one array to display it – Omkar Desai Jul 02 '21 at 08:00
  • You have another collection inside `driver`, so how could you directly access the `dName` ? – Kundan Jul 02 '21 at 10:20
  • Have a look at this https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query – Kundan Jul 02 '21 at 10:23
  • Does this answer your question? [Firestore query subcollections](https://stackoverflow.com/questions/46573014/firestore-query-subcollections) – Kundan Jul 02 '21 at 10:23

0 Answers0