FirebaseExtended / polymerfire

Polymer Web Components for Firebase
https://www.webcomponents.org/element/firebase/polymerfire
MIT License
459 stars 142 forks source link

Added reversed order for firebase-query #351

Closed iSuslov closed 1 year ago

iSuslov commented 6 years ago

This is very requested feature for lists sorted by timestamp. No need to store timestamp in negative order to get DESC order. Usage:

<firebase-query reversed path="..." order-by-child="..." limit-to-last="..."></firebase-query>

This is initialisation parameter, can not be changed dynamically to generate new query. But if new query created, it will take effect if this parameter was changed before results came to a client.

tjmonsi commented 6 years ago

Hi, this is a good initiative but I don't think it is necessary as reverse flag or any sort of functionality that reverses the array is not part of the original firebase methods as stipulated here - https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot and https://firebase.google.com/docs/reference/js/firebase.database.Reference#on. I am thinking that to really keep it simple, it should just follow the methods that only exists in the docs. Besides, the idea is that it will be sorted given the order-by-child attribute.

Reversing can also be done in the dom-repeat part or even on the sorting part after getting the data.

iSuslov commented 6 years ago

Hi, since it is a helper element I think it makes little sense to just copy API from firebase documentation and incapsulate it so that modifying operation(sorting) would be much costlier to perform after. Exists property is not from documentation also, but it helps tracking first load and is generally very useful feature of this element. Sorting will be performed not only on the first load, but also on each child_moved child_removed child_added event. And this changes should be observed via splices if not using dom-repeat. With all this said, it will have a huge performance impact.