angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Docs update: Querying sub collections examples

Open fellz opened this issue 8 years ago • 3 comments

Hi Could you add some examples how to query sub collections. For example, we have profiles collection and likes sub collection. So query for profiles collection would be something like this:

let q = db.collection<Profile>('profiles', ref => ref.where('uid', '==', user.uid)).valueChanges(); q.subscribe(res =>  this.profile = res[0] ) ;

Profile doesn't have any refs to sub collection. If i'd use snapshotChanges() result the same.

fellz avatar Feb 06 '18 16:02 fellz

You can't do that with SubCollections. Try db.collection(profile).document(user.uid).collection(likes) or define likes as an array if you want it to appear in valueChanges.

I don't see this as a special feature of angularfire2 so I don't think this should be included in docs.

houfu avatar Feb 13 '18 04:02 houfu

@fellz did you solve it?

MurhafSousli avatar Apr 25 '18 12:04 MurhafSousli

Not implemented yet in firestore. Have a look at this post. https://stackoverflow.com/questions/46573014/firestore-query-subcollections What you can do for now is to query your collection first, then get it's id and query for subcollections

jcuervas avatar Apr 28 '18 13:04 jcuervas