How do I use AngularFire OrderByDirection?

55 views Asked by At

I am looking for documentation for AngularFire OrderByDirection I have the code shown below and wherever I attempt to add OrderByDirection = 'desc' to the code I receive the error; 'OrderByDirection' only refers to a type, but is being used as a value here.ts(2693). I think it should be in the initial getting the =collection() or the inside the =query(); but without docs I am flying blind. I can cheating use orderBy from firebase/firestore, but mixing the two would be a bad idea.

ts.

import { addDoc, collection, collectionData, doc, Firestore, query, updateDoc, OrderByDirection } from '@angular/fire/firestore';
import { orderBy } from "firebase/firestore";

getFireStoreCollection( id: any) {
  const messageColection = collection(this.firestore, `tasks/${id}`);
  const messQuery = query( messageColection );
 //messQueryCheating works but mixes angularfire and firebase/firestore
  const messQueryCheating = query( messageColection, orderBy("time", "asc") ); 
  const collectionSub = collectionData(messQuery, 
      {  idField: 'id'}) as Observable<Messages[]>;
    this.messagesSub = collectionSub.subscribe((mess) => { this.messages.next(mess) });
    return this.messages.asObservable();
}
0

There are 0 answers