DS.JSONSerializer#keyForRelationship()

keyForRelationship (key, typeClass, method) String

Defined in addon/serializers/json.js:1458

keyForRelationship can be used to define a custom key when serializing and deserializing relationship properties. By default JSONSerializer does not provide an implementation of this method.

Example

app/serializers/post.js
 import DS from 'ember-data';

 export default DS.JSONSerializer.extend({
   keyForRelationship: function(key, relationship, method) {
     return 'rel_' + Ember.String.underscore(key);
   }
 });

Parameters:

key String
typeClass String
method String

Returns:

String
normalized key
doc_EmberJs
2016-11-30 16:49:50
Comments
Leave a Comment

Please login to continue.