Code Monkey home page Code Monkey logo

Comments (3)

pablorsk avatar pablorsk commented on August 29, 2024

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?

from ngx-jsonapi.

leetharris avatar leetharris commented on August 29, 2024

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 array_order attribute to each item in the collection.

Then we sorted our tables by this array_order attribute on each resource. Worked out pretty well!

Thanks for making this package!

from ngx-jsonapi.

OpticNectar avatar OpticNectar commented on August 29, 2024

@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.

from ngx-jsonapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.