1

I am working on a new Ember.js project using Rails as backend, and Mongodb as database. Basically it's Starcraft 2 replay analyzer, like ggtracker.com (which powered by angularjs)

Current data structure for my model: http://paste.kde.org/pd3582db1/

I don't know even how to begin defining it, seems like ember-data is missing a complex type field, and defining each sub model will take like forever (The current model doesn't contain the entire data)

Thanks in advance, BBLN.

BBLN
  • 495
  • 6
  • 19

1 Answers1

2

You don't have to use Ember-Data, you can use pojos. Ember-Data is just one of the many "simplified" ways of using models, there is also Ember-Model. That being said, if you created a new Ember object with that huge pojo you'd be accessing it something like this:

 var someModel = Ember.Object.create(bigOlJSON);
 someModel.get('players.firstObject.abilities.firstObject.blahblahblahblah');

 or you could slowly build it up

 var players = [];
 someModel.get('players').forEach(function(player){
    players.push(Ember.Object.create(player));
 });

 //At this point players is loaded with a slew of player data

That seems a little too monstrous to me.

I'd think it would almost be beneficial to map out all of the models, and set them as embedded models.

See this post for embedded records for Ember Data: Ember-data embedded records current state?

Community
  • 1
  • 1
Kingpin2k
  • 47,277
  • 10
  • 78
  • 96
  • Thank you! Seems like I would need to use `embedded: 'always'` instead, but at least I know where to begin from. – BBLN Aug 19 '13 at 15:54
  • with latest ember `embedded: 'always'` in the model doesn't work, need to override serializer instead (http://emberjs.com/api/data/classes/DS.EmbeddedRecordsMixin.html) – RomanI Jul 19 '14 at 22:35
  • Oh yeah, this response is almost a year old, check out this, http://stackoverflow.com/questions/24222457/ember-data-embedded-records-current-state/24224682#24224682 – Kingpin2k Jul 19 '14 at 22:41