How to reverse order of items from Firebase

前端 未结 2 401
花落未央
花落未央 2021-01-16 15:56

How can I reverse the order of this list in from Firebase? I want the last item to be the first. I tried to use queryOrdered, but that did not make a difference

2条回答
  •  温柔的废话
    2021-01-16 16:48

    One trick that I'm using is to add a field to my object that stores the time-stamp as reversed value. The value of this field I compute when I persist the object and is reversedDateCreated = timeStamp * -1 Now you can use default Firebase orderBy methods in order to sort and paginate by reversedDateCreated field

提交回复
热议问题