javascript - Angular Firestore Sorting documents by timestamp value - Stack Overflow

I have a question which I'm hoping someone could answer as it's been two days I'm trying

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'))
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745215206a4616976.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信