ember.js - Ember data - send only properties that have values -
i have model many attributes , associations. of them may or may not null. trying ajax call model payload, , properties can null.
i want send properties have values, , not null, including associations.
is possible? kindly let me know if possible.
export default ds.model.extend({ name : ds.attr('string'), address : ds.hasmany('address') });
for should override serializer. if use default jsonapiserializer right place serializeattribute hook:
export default ds.jsonapiserializer.extend({ serializeattribute(snapshot, json, key) { if(snapshot.attr(key) != null) { this._super(...arguments); } } }); this work attributes, not relationships. same.
you can write own serializer. implement serialize hook, , write code want create json want.
Comments
Post a Comment