Reputation: 676
I'm currently developing a web app in angular 5 with firebase. Anyway I'm using angular/firestore2 for that purpose.
The problem I have is that I cannot access my top-level collection. My structure is something like
Collection(top level collection ['events']) -> Docs(related to userId) -> Collection -> Docs
If I'm trying to access top level within
return this.db.collection('events').valueChanges();
It returns empty array, although there are documents inside that collection. Anyway If I make new custom collection like:
Collection (top level collection ['tests']) -> Docs
and I try to access that collection within
return this.db.collection('tests').valueChanges();
It returns the array with the docs inside.. I'm really confused and would appreciate any help..
I'm using https://github.com/angular/angularfire2 for firestore/storage connections.
Upvotes: 0
Views: 478
Reputation: 83058
I am not 100% sure of what follows since I don't use angular/firestore2 but it says in the documentation that "The AngularFirestoreCollection service is a wrapper around the native Firestore SDK's CollectionReference
and Query
types".
Queries in Firestore are shallow queries, therefore when you make a modification in a document under a sub-collection, the listener declared at the collection's parent document will not be fired.
What is explained in the "standard" Javascript SDK documentation for the onSnapshot()
method is similar: "You can listen to a document with the onSnapshot()
method." It does not include changes in the document's sub-collections.
Upvotes: 1