vendredi 26 mars 2021

Ember.JS Data Model save() errors with 'options is undefined'

I've got a small snippet of code, where I check for a model existing in the current data store. If it doesn't already exist I create it and save it. This used to work on an older version of ember-cli (3.8), however throws this error as of an upgrade to 3.21.

let myModel = this.store.peekRecord('modelName', this.newModelId);

if (!myModel) {
    myModel = this.store.createRecord('modelName', {
        id: this.newModelId
    });


    await myModel.save({});
}

When executing model.save() it errors out with options is undefined, stepping into the code for save, it shows options being passed as a parameter of save(), however the ember documentation and everywhere else, save is used with no parameters.

Any help as to why this error is being thrown would be very helpful, thank you.




Aucun commentaire:

Enregistrer un commentaire