Ahmed Wagdi
Ahmed Wagdi

Reputation: 4391

how to order query From firestore based on timestamp in ionic 4

I've performed a query to Firebase firestore and the data is being called perfectly. but I can't use any kind of ordering on this query.

here is my code:

   this.dressCollection = db.collection<Dress>('dress').orderBy("date", Query.Direction.ASCENDING);
    this.dress = this.dressCollection.snapshotChanges().pipe(
      map(actions => {
        return actions.map(a => {
          const data = a.payload.doc.data();
          const id = a.payload.doc.id;
          return { id, ...data };
        });
      })
    );

I get this 2 errors:

Property 'orderBy' does not exist on type 'AngularFirestoreCollection<Dress>'

and

Cannot find name 'Query'

Upvotes: 0

Views: 698

Answers (1)

Alam
Alam

Reputation: 321

Use

, 'date',ref=>ref.orderBy('date','asc')

inside the collection

Upvotes: 1

Related Questions