EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

How to query a single field of a document in firestore firebase? #798

Open it3r4-pineda opened 6 years ago

it3r4-pineda commented 6 years ago

example I added this document in collection

PostCollection.add({ name: "San Francisco", state: "CA", country: "USA", capital: false, population: 860000, location: firebase.firestore().GeoPoint(4.34, 5.67) }).then(documentRef => { console.log(San Francisco added with auto-generated ID: ${documentRef.id}); });

then I want to query the document but only want the value of “name”. how do I modify this code to achieve the above?

PostCollection.get().then(querySnapshot => { querySnapshot.forEach(doc => { console.log(${doc.id} => ${JSON.stringify(doc.data())}); }); });

EddyVerbruggen commented 6 years ago

I'm not sure what you're after. Do you want doc.data().name?