How to retrieve a sub collection with ngx-labs/firestore

Viewed 67

In my projects, I've some collection of data that are related only to the logged user. So the path to those items is /users/{userId}/checkins. It will be easy to set a security rule in firebase, and I think it will be quite efficient since I never need the checkin of other people.

How can I specify this in the NgxsFirestore implementation?

I currently have this:

import { Checkin } from './checkins.model';
import { Injectable } from '@angular/core';
import { NgxsFirestore } from '@ngxs-labs/firestore-plugin';

@Injectable({
  providedIn: 'root',
})
export class CheckinsFirestore extends NgxsFirestore<Checkin> {
  protected path = 'users/{userId}/checkins/2021';
  idField = 'checkinId'
}

I guess I could inject AngularFireAuth, and register to the authState to compute this path, but since it's a property, it will probably be too late.

Thank you for your guidance.

0 Answers
Related