Reputation: 113
I have a question which I'm hoping someone could answer as it's been two days I'm trying to sort it with absolutely no luck.
I have a collection of documents, so far so good..
Each of this documents has a field "preferred_time" that has a timestamp as a value.
Is it possible to sort the documents inside the collection using this value as reference?
I tried:
return this.afs.collection('viewings', ref =>
ref.orderBy('preferred_time')
);
but it doesn't seem to work with timestamps field types.
Please help!!
Thanks, M.
Upvotes: 3
Views: 5692
Reputation: 818
You can sort your preferred_time on desc or asc. Read more here: https://firebase.google.com/docs/firestore/query-data/order-limit-data
return this.afs.collection('viewings', ref =>
ref.orderBy('preferred_time','desc'))
);
Upvotes: 5