Adding inclusion of hasMany relationship while creating a record

Hi guys,

I am creating a crud operation and I already created rest api in golang and revel.Now I am integrating frontend as ember.I have two models one is user and another is address.There relationship is user hasMany address.However i will store user and address object as a single json document in mongodb only address will be embedded.While creating a record with post request ,my api need following json format :- https://github.com/rishirajdev/jsonAPIUnmarshal/blob/master/jsonFormat

however ember send request in the below json format: http://jsonapi.org/format/#crud-creating

How can I make ember to send json format the same which my api accepts

1 Like

Great question, @rishirajdev. Unfortunately it seems there is no answer in the current version of the JSON API spec, see: https://github.com/json-api/json-api/issues/795

However, there may be workarounds that Iā€™d be interested in exploring.

hi @emberigniter

I found a way to customize the json sent to the backend server.

Here is the serialization function for customizing post request data sent to the server.

@rishirajdev you might be interested in this: Saving Models and Their Relationships with JSON API - Ember Igniter