vendredi 16 octobre 2015

Ember Data: Mapping Arrays

I am trying to define an Ember Data Model from the following response I am getting from the API. I am having issues defining the num_activity_per_map field since its an array of JSON objects however they do not have an id. If I use DS.hasMany('activityPerDate', {async:true}) complains it doesn't have a primary key.

{
"stats": {
    "num_users": 44,
    "num_activity_per_date": [
        {
            "date": "04-10-2015",
            "count": 6
        },
        {
            "date": "05-10-2015",
            "count": 8
        },
        {
            "date": "06-10-2015",
            "count": 7
        },
        {
            "date": "07-10-2015",
            "count": 5
        },
        {
            "date": "08-10-2015",
            "count": 3
        }
    ],
  }
}




Aucun commentaire:

Enregistrer un commentaire