I need to serialize Ember-data to JSON and use the JSON to feed this JS Library: http://www.jstree.com/docs/json/
I don't how to achieve this. DS.RESTSERIALIZER with DS.EmbeddedRecordsMixin should be able to achieve this but I dont know how to call them in my Ember-CLI app. They seem to be built to only speak to a backend. My backend is Firebase with the Emberfire adapter and I don't want to change it. Is DS.RESTSERIALIZER what I need to you use? Should I use JSON.stringify() instead?
My model is:
import DS from 'ember-data';
export default DS.Model.extend({
text: DS.attr('string'),
order: DS.attr('number', { defaultValue: 0 }),
cause: DS.belongsTo('cause', { inverse: 'causeUnitLink', async: true}),
causeUnit: DS.belongsTo('causeUnit', { inverse: 'causeUnitLinks', async: true}),
parents: DS.hasMany('causeUnitLink', { inverse: 'children', async: true}),
children: DS.hasMany('causeUnitLink', {inverse: 'parents', async: true}),
});
I have created the below sterilizer but I don't know how to invoke its methods in my controller so I can turn the ember-data into JSON and feed the JSON to my jsTree component.
import DS from 'ember-data';
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
text: { embedded: 'always' },
children: { embedded: 'always' }
},
});