Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit b235f1c

Browse files
Fixed a reference example
1 parent c83f2aa commit b235f1c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

demo-ng/app/item/items.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,7 @@ export class ItemsComponent {
123123
const collectionRef: firestore.CollectionReference = firebase.firestore().collection("dogs");
124124
collectionRef.get()
125125
.then((querySnapshot: firestore.QuerySnapshot) => {
126-
querySnapshot.forEach(doc => {
127-
console.log(`${doc.id} => ${JSON.stringify(doc.data())}`);
128-
// since there's a reference stored here, we can use that to retrieve its data
129-
const docRef: firestore.DocumentReference = doc.data().ref2sf;
130-
docRef.get().then(res => console.log("docref.get: " + JSON.stringify(res.data())));
131-
});
126+
querySnapshot.forEach(doc => console.log(`${doc.id} => ${JSON.stringify(doc.data())}`));
132127
})
133128
.catch(err => console.log("Get failed, error" + err));
134129

@@ -138,6 +133,9 @@ export class ItemsComponent {
138133
docRef.get().then((doc: firestore.DocumentSnapshot) => {
139134
if (doc.exists) {
140135
console.log("Document data:", JSON.stringify(doc.data()));
136+
// since there's a reference stored here, we can use that to retrieve its data
137+
const docRef: firestore.DocumentReference = doc.data().referenceToCitiesDC;
138+
docRef.get().then(res => console.log("docref.get: " + JSON.stringify(res.data())));
141139
} else {
142140
console.log("No such document!");
143141
}

0 commit comments

Comments
 (0)