Discussions

Ask a Question
Back to All

Nested endpoint with shared id

I am attempting to use an API that has the following endpoint layout. I'm not sure how to define the resources in js-data to match it.

GET /api/buildings
Returns an array of buildings

GET /api/buildings/90
Returns an object containing a summary from the specified building

GET /api/buildings/90/info
Returns an object containing detailed information from the specified building

PUT /api/building/90/info
Update the information of a building

The building endpoint and the info endpoint share the same ID.

I have two resources defined: Building and BuildingInfo. My first thought was to define a belongsTo relationship in BuildingInfo with parent = true, however this results in js-data generating a url containing the ID twice (/api/building/90/info/90).

I suspect js-data does not support this use case currently. I'm hoping to find out how I can do it with minimal changes to js-data.