I am integrating with an api that exposes child resources nested under parent resources.

This seems to work fine when I am finding or creating resources from JSData, however, updates and deletes seem to want to access the resource directly.

GET & POST:
/api/parents/:parent_id/children

But, with delete and put requests:

DELETE & PUT
/api/children/:child_id

It seems like if there is a object id involved for the child record then the url that is constructed is constructed at the base level of the API, and if there is no object id, as is the case with POST and GET (findAll).

Is there something very obvious that I am missing here?

1

There are 1 answers

0
Apie On BEST ANSWER

After reading a bit more about relations in JS-Data here: http://www.js-data.io/docs/relations

I saw this part,

    // if you add this to a belongsTo relation
    // then js-data will attempt to use
    // a nested url structure, e.g. /organization/15/user/4
    parent: true

under the "Defining Relations" header. I had two relations with the parent: true configuration which I think confused JS-Data's router.