I had a function that was saving multiple todos to a list.
list.save().then(function(list) {
list.get('todos').then(function(todos){
todos.forEach(function(todo){
todo.save();
});
});
});
user.get('todos').then(function(user){
user.save();
)};
But now I'm using Firebase to store session.uid, so I need to use instead
ref.child('lists').push({
user: uid,
todo: this.get('todo')
});
But it doesn't work. (Also I don't know where forEach from the previous version of code fits in here). I've tried
todo: this.get('model.todo')
as well. I think it's because of the way todos are added (I'm saving todos only after list is saved because of parent-child relationship)
addTodo: function() {
var user = this.controllerFor('application').get('model');
var todo = this.store.createRecord('todo', {
title: this.get('model.todos.title'),
user: user,
});
var list = this.get('model');
list.get('todos').pushObject(todo);
I'm getting the error
Firebase.push failed: first argument contains undefined in property 'lists.todo'
Any help would be appreciated!
Aucun commentaire:
Enregistrer un commentaire