Comments (5)
@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.
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.
@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.
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.
@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)
- Proposal: Include ember-getowner-polyfill HOT 3
- [question] Make related-proxy computed property volatile? HOT 6
- changedRelationships does not track first hasOne HOT 4
- [question] Similaries/differences with `DS.JSONAPIAdapter`? HOT 1
- Broken build with older version of fetch & es6-promise packages
- Replace fetch mixin with ember-fetchjax addon
- Name Relationship helper: toMany and toOne
- Ember Inspector `Data` tab is throwing an error HOT 2
- changedAttributes and changedRelationships not live. HOT 1
- Fix ember-beta [2.12.0-beta.2] test failures.
- Can not handle 204 no content for updating resources. HOT 2
- Full tests
- Looking for a new maintainer HOT 1
- Update to authorization mixin to support ember-simple-auth 1.0 HOT 1
- Update docs for [create|patch|delete]Relationship service methods HOT 1
- model generator/blueprint broken? HOT 4
- Move Resource#updateRelationship to a mixin
- has-one relation may be empty so need to handle a `data: null` response
- [Question] Working with Katharsis dialect for included resources, sorting, and sparse fieldsets HOT 1
- Proposal: Change key 'resource' to 'relation' in hasOne/hasMany object param. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-jsonapi-resources.