devour-client
devour-client copied to clipboard
Relationships: Improve docs and replace strings with constants
When specifying relationships via hasOne and hasMany, i do not like that i have to rely on those magic strings - and could easily make a mistake typing them out.
I propose replacing them by static constants, which are available on the JsonApi class. This way, it is possible to use in it the code as following:
import JsonApi from 'devour-client'
...
myApi.define(
'post',
{
name: '',
comments: {
jsonApi: JsonApi.HAS_MANY,
type: 'comments',
}
},
)
Either way, it would be nice if the section Relationships clearly listed the available types of relationships and provided an example for it.
I would be willing to create a pull request if you think this change is a good idea.