-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bug: The package sorts all incoming data by "id" automatically. #54
Comments
Library works with collections. Every element on collection has the resource id as key. Javascript sort collections by key. On my mind, we have only solution: replace collections for arrays. This solution is very aggressive, because we need change a lot of features. Collections are very fast, because we save cache on memory and browser index db; we need only ask if element exists. If we migrate to array, we need on every interaction traverse all data (imagine relations on each resource of a collection). Another better idea? |
We actually made our own workaround for this which may give you some inspiration on how you could handle it in your package. We created a middleware that checked all incoming arrays and assigned an Then we sorted our tables by this Thanks for making this package! |
@leetharris Could you share your code on this? @pablorsk The order should be based on the server or there should be a sort option. Automatically sorting by ID defeats the purpose of what a lot of this package does, especially since jsonapi itself supports sorting. |
Version 1.1.0 🎆 * Feature: collections has `data` member now. `data` is an array, and the requested information is kept in order. Closes #84. Closes #54. * Feature: trackBy added on collection. Optimize use of ngFor. * Deprecated: callback functions deprecated on get(), all(), detele() and save(). And... * Demo: demo-collection-info component added. Show info about received collection. * tslint: array<> to [] on types * version 1.1.0 bump * Readme updated: sort and trackby added
As the title states, this package sorts all incoming data by "id" and does not preserve the original order.
This is a problem as we have specific ordering coming out of our backend based on remote "sort" parameters (supported by the JSON-API spec).
The text was updated successfully, but these errors were encountered: