Closed rosslavery closed 9 years ago
limitToLast() doesn't actually reverse the order of the elements, it simply fetches the last x
items. If that's the goal, then Scroll isn't necessary, as it's designed to work with an unspecified number of items (quasi-infinite lists).
Regarding actual reversal: this is a limitation of the queries API; until one can reverse the items in the query, Firebase.util.Scroll won't be able to help here.
Got it, thanks for the response Kato.
I'll close this now, hopefully the queries API gets that feature in a future release!
Thanks for the great work on the latest release.
I'm looking to use the Scroll class on a collection of comments, where they each have a timestamped
createdAt
field. The items need to be ordered with the most recent at the top. I can passcreatedAt
to the Scroll class, but it usesorderByChild
which orders them with the oldest first.Scroll seems to only lets you pass a raw firebase reference to it, not a Query, so I can't use
limitToLast()
to reverse the order that the items are loaded in.When using
limitToLast
on the scrollRef, it throws:But when using limitToLast on the original reference as indicated, it throws:
Reversing the collection on the client doesn't seem like a possibility because Scroll is loading comments in via "pages" from the opposite end of the collection. Hopefully that makes sense...
I understand Scroll is using Queries internally, so passing it a query would break it since chaining Queries isn't possible, but is there an optimal strategy for this?