Git Product home page Git Product logo

Comments (5)

pixelhandler avatar pixelhandler commented on June 7, 2024

@barelyknown at first I didn't use the hasRelated method only a relationships object. later I found a need to setup the object so I added this method to setup the relationships object. but I'm open to changing that, it came it mostly to make things work. I still like the idea of declaring the relationships object in the resource prototype. A JSON API resource has props for id, type, links, relationships, attributes. The hasOne and hasMany setup the computed properties using a promise proxy to fetch the related objects. Perhaps hasRelated() should just become relationships() that would be more inline with the definition of a resource that is represented by the JSON API. I considered avoiding it altogether and using the hasOne and hasMany to setup the relationships' (links) objects with { links: {}, data: null }, see https://github.com/pixelhandler/ember-jsonapi-resources/blob/master/addon/models/resource.js#L160-L170

from ember-jsonapi-resources.

barelyknown avatar barelyknown commented on June 7, 2024

It felt to me like it should just be relationships() and that hasOne() and hasMany() should setup the relationships object using newRelation(). Otherwise, users might be confused about why they have to declare the relationship twice.

from ember-jsonapi-resources.

pixelhandler avatar pixelhandler commented on June 7, 2024

@barelyknown the computed properties don't access the model (this) until a get is called (I think); so I was concerned that I needed to setup the relationships objects, straight-away. If the resource is serialized the relationships part of the resource would be accurate.

At first it seem odd to declare the releationships, then also the related proxies to those related resources; essentially they are two things - one is for the structure of the resource's relationships objects and the other (hasOne / hasMany ) is for actual proxied (related) resources.

from ember-jsonapi-resources.

barelyknown avatar barelyknown commented on June 7, 2024

It seems like there should be something above hasOne()/hasMany() and hasRelationships() that sets up the proxy and adds to the relationships. Maybe that's too much "magic" and doesn't matter much, but it seems like now is the time to talk about the API. I also wanted to make sure that I understood why you made the choice (and I do).

from ember-jsonapi-resources.

pixelhandler avatar pixelhandler commented on June 7, 2024

@barelyknown I'll put the change in the next release to use only hasOne() hasMany() and setup the reltationships object during init.

from ember-jsonapi-resources.

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.