Adding inclusion of hasMany relationship while creating a record


#1

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


Learning more about serialization in Ember
#2

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.


#4

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.


#5

@rishirajdev you might be interested in this: http://emberigniter.com/saving-models-relationships-json-api/