Skip to content

Instantly share code, notes, and snippets.

@consideRatio
Last active January 2, 2016 04:29
Show Gist options
  • Save consideRatio/8250757 to your computer and use it in GitHub Desktop.
Save consideRatio/8250757 to your computer and use it in GitHub Desktop.
SpeedMind.M = DS.Model.extend({
mms : DS.hasMany('mm'),
name : DS.attr('string')
});
SpeedMind.Mm = DS.Model.extend({
m : DS.belongsTo('m'),
name : DS.attr('string'),
mmms : DS.hasMany('mmm')
});
SpeedMind.Mmm = DS.Model.extend({
mm : DS.belongsTo('mm'),
name : DS.attr('string')
});
{
"m": {
"id": 1,
"name": "m1",
"mms": ["1", "2"]
},
"mm": [{
"id": "1",
"name": "mm1",
"mmms": ["1", "2"]
}, {
"id": "2",
"name": "mm2",
"mmms": ["3", "4"]
}],
"mmm": [{
"id": "1",
"name": "mmm1"
}, {
"id": "2",
"name": "mmm2"
}, {
"id": "3",
"name": "mmm3"
}, {
"id": "4",
"name": "mmm4"
}]
}
Background:
* i wanna use a local storage adapter
* i can reformat the JSON if i want
Question: How can I, using json above, add that data? What methods should i use?
SpeedMind.Store = DS.Store.extend();
SpeedMind.LSAdapter = DS.LSAdapter.extend({
namespace: 'SpeedMindData'
});
SpeedMind.ApplicationAdapter = DS.LSAdapter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment