Update
For anybody who also is having similar problem in the future. I am not sure why the ObjectiveC-SDK with documentWithPath and documentWithCollection is not working but what i have found is if we directly give the path it can work.
So instead of asking
self.db collectionWithPath:@"stage_tickets"]documentWithPath:bookingReference]collectionWithPath:@"tickets"]getDocumentsWithCompletion
and getting nothing in return you can directly write the path
self.db collectionWithPath:@"stage_tickets/{bookingReference}/tickets"]getDocumentsWithCompletion
I have a Cloud FireStore database with a structure like this.
The Structure is basically stage_tickets(Collection)->Numbers(Documents)->Tickets(Collection)->Numbers(Documents)
The really Strange thing is if i want to get all the numbers from the first level i can easily get them via
[[self.db collectionWithPath:@"stage_tickets"]
getDocumentsWithCompletion:^(FIRQuerySnapshot *snapshot, NSError *error) {
if (error != nil) {
NSLog(@"Error getting documents: %@", error);
} else {
for (FIRDocumentSnapshot *document in snapshot.documents) {
NSLog(@"%@ => %@", document.documentID, document.data);
}
}
}];
But if i try to reach the second level of numbers via
[[[[self.db collectionWithPath:@"stage_tickets"]documentWithPath:bookingReference]collectionWithPath:@"tickets"]getDocumentsWithCompletion:^(FIRQuerySnapshot * _Nullable snapshot, NSError * _Nullable error) {
if(error!=nil){
NSLog(@"error in getting QR Code");
}else{
for (FIRDocumentSnapshot *document in snapshot.documents) {
NSLog(@"%@ => %@", document.documentID, document.data);
}
}
}];
All i get is empty documents in Snapshot. Can anybody suggest what is wrong i am doing here, maybe some behaviour of fireStore that i am unaware of and how can i fix this.
question from:
https://stackoverflow.com/questions/66057216/get-all-documents-for-a-sub-collection-in-firebase-cloud-firestore 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…