lundi 11 avril 2016

Update record in Ember.js 2.4

Apologies in advance, I'm very new to Ember and javascript.

I've been following the tutorial at http://ift.tt/1XrtS4q

He's introduced a pattern of creating components and putting all of the actions in the components and routes instead of using a controller. I want to know how to update a record in the database (firebase).

I didn't explicitly create an ID in my model, so I was trying to find a specific record using one of the attributes, but it's not working. I get the error of

Error: no record was found at http://ift.tt/1TNaW17

Which I think is happening because my syntax for findRecord is wrong. I thought I was following the convention as described in the docs http://ift.tt/1XrtR0x

updateTask: function (model) {
  let task = this.store.findRecord('task', 'taskname').then(function(task){
    task.set( 'taskname', model.taskname);
    task.set( 'startdate', model.startdate);
    task.set( 'enddate',  model.enddate);
    task.set( 'banding',  model.banding);
  });
  task.save();
}

then additionally I get an error

Uncaught TypeError: undefined is not a function index.js:26
updateTask

which appears to be thrown by the same function. can anyone redirect me here?

Aucun commentaire:

Enregistrer un commentaire