ngxs-labs / firestore-plugin

Firestore plugin for NGXS
https://ngxs-firebase-plugin.netlify.com/
MIT License
20 stars 14 forks source link

Query documents inside a Subcollection #22

Closed lyamone closed 3 years ago

lyamone commented 3 years ago

Hi guys,

First of all, I would like to thank you because the library is great but I am struggling to query a subcollection.

I have the following service which extends the Ngxs Firestore Class and where I set the path to the parent collection:

import { Injectable } from '@angular/core'; import { Course } from '@course/course.model'; import { NgxsFirestore } from '@ngxs-labs/firestore-plugin'; @Injectable() export class CourseService extends NgxsFirestore<Course> { protected path = 'course'; } The problem comes when I want to query all the documents within a Subscribers subcollection. The path looks like this: course/courseId/subscriptions

I tried to change the path with a dynamic one without luck.

In the Angular Fire documentation is possible to query subcollection because we can get the reference:

constructor(private afs: AngularFirestore) { this.userDoc = afs.doc<Item>('user/david'); this.tasks = this.userDoc.collection<Task>('tasks').valueChanges(); }

Is there a way that I am missing to get subcollections? or It's a feature not supported yet in the library?

Thanks!!

joaqcid commented 3 years ago

Duplicate of #21