admin管理员组

文章数量:1415684

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.

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.

Share Improve this question asked Apr 11, 2018 at 18:07 CyberpunkerCyberpunker 1131 gold badge2 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You can sort your preferred_time on desc or asc. Read more here: https://firebase.google./docs/firestore/query-data/order-limit-data

 return this.afs.collection('viewings', ref => 
ref.orderBy('preferred_time','desc'))
);

本文标签: javascriptAngular Firestore Sorting documents by timestamp valueStack Overflow