Open it3r4-pineda opened 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}); });
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(
); });
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())}); }); });
PostCollection.get().then(querySnapshot => { querySnapshot.forEach(doc => { console.log(
); }); });
I'm not sure what you're after. Do you want doc.data().name?
doc.data().name
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())}); }); });