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

Commit 9827c84

Browse files
#559 Firestore nested collections
1 parent 9759c2d commit 9827c84

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
### Fixes
1313
- [#563](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/563) Initialization problem on 5.0.2 on iOS
14+
- [#559](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/559) Firestore nested collections
1415

1516

1617
## 5.0.2 (2017, December 1)

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,19 @@ export class ItemsComponent implements OnInit {
141141
}
142142

143143
public firestoreGetNested(): void {
144-
const streetsColRef: firestore.CollectionReference =
144+
const mainStreetInSFDocRef: firestore.DocumentReference =
145145
firebase.firestore()
146146
.collection("cities")
147147
.doc("SF")
148-
.collection("streets");
148+
.collection("streets")
149+
.doc("QZNrg22tkN8W71YC3qCb"); // id of 'main st.'
149150

150-
streetsColRef.get().then((querySnapshot: firestore.QuerySnapshot) => {
151-
querySnapshot.forEach(doc => {
152-
console.log(`${doc.id} => ${JSON.stringify(doc.data())}`);
153-
});
151+
mainStreetInSFDocRef.get().then((doc: firestore.DocumentSnapshot) => {
152+
if (doc.exists) {
153+
console.log("Document data:", JSON.stringify(doc.data()));
154+
} else {
155+
console.log("No such document!");
156+
}
154157
}).catch(function (error) {
155158
console.log("Error getting document:", error);
156159
});

src/firebase.android.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,8 +2197,6 @@ firebase.firestore.collection = (collectionPath: string): firestore.CollectionRe
21972197
return null;
21982198
}
21992199

2200-
console.log(">> collection, collectionPath " + collectionPath);
2201-
22022200
const db = com.google.firebase.firestore.FirebaseFirestore.getInstance();
22032201
const collectionRef: com.google.firebase.firestore.CollectionReference = db.collection(collectionPath);
22042202

0 commit comments

Comments
 (0)