0

I am trying to manually load data into store. Here is the link to the jsBin http://jsbin.com/uYUsuTu/1/edit?html,output

My model is defined as :

    AS.AnalyticsRun = DS.Model.extend({
        'exerciseId': DS.attr('number'),
        'exerciseRunId': DS.attr('number'),
        'evolutionRunIds': DS.attr('string'),
        'analyticsTemplateId': DS.attr('number'),
        'analyticsPlan': DS.attr('string'),
        'commandScript': DS.attr('string'),
        'queued': DS.attr('boolean'),
        'final': DS.attr('boolean'),
        'createdBy': DS.attr('string'),
        'dateCreated': DS.attr('date'),
        'lastUpdatedBy': DS.attr('string'),
        'lastUpdated': DS.attr('date'),
        'analyticsRunParameters': DS.attr('string'),
        'evolutionRuns': DS.hasMany('evolutionRun')
    });

and I am trying to load data into store like:

var run = {"analyticsRun": [{"id": 2,
            "exerciseId": 1885,
            "exerciseRunId": 1938,
            "evolutionRunIds": null,
            "analyticsTemplateId": 13,
            "analyticsPlan": null,
            "commandScript": "test",
            "queued": false,
            "final": false,
            "createdBy": "Deewendra Shrestha",
            "dateCreated": "2013-10-04T13:40:23Z",
            "lastUpdatedBy": "Deewendra Shrestha",
            "lastUpdated": "2013-10-04T13:40:23Z",
            "analyticsRunParameters": null,
            "evolutionRuns": []}],
    "evolutionRuns": [
        {"id": 1378, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KK2"},
        {"id": 1375, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KM1"},
        {"id": 1377, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KM2"},
        {"id": 1371, "name": "aff_parameters_dannon.Pretest.Dannon_pman_control"},
        {"id": 1376, "name": "aff_parameters_dannon.Pretest.Dannon_pman_KK1"}
    ]};
this.get('store').push('analyticsRun', run);

to which I get the error

You must include an id in a hash passed to push

Not sure what I did wrong here!

Thanks, Dee

2 Answers 2

3

Maybe you should use:

this.get('store').pushPayload('analyticsRun', run);

Creating an object is not the same as pushing it...

Sign up to request clarification or add additional context in comments.

Comments

0

OK, I got things working by using :

this.get('store').createRecord('analyticsRun', run);

instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.