I'm using Ember-data and the JSON API Adapter, I have a particular model widgets
which has a nested route /widgets/default
, which when posted to will setup a default set of relationships required for adding a new 'widget'. Essentially it's a shortcut method for adding a widget and saves doing lots of posts to separate relation endpoints after creating each widget. The idea is that we want to have numerous preset types of widgets which can be created in one post, each with different sets of relationships.
I have searched the docs for Ember data but could not see anything that would allow this out of the box. Does anyone know if it's possible to use nested routes when creating a record with the JSONApi adapter?
Here's an example of what I'd like to do in pseudo code:
this.get('store').createRecord('widget.default', attrs).save().then((widget)=>{
this.get('router').transitionTo('widgets.edit', widget.id);
});
So calling createRecord on widget.default
would trigger it to post the payload to the /widgets/default
endpoint, rather than to /widgets
.