saveTodoList(todoList) {
    this.db.prepare('DELETE FROM tasks WHERE tasks.todo_list_id = 1').run();
    for (let task of todoList.tasks) {
      task.isComplete = (task.isComplete ? 1 : 0);
      task.isImportant = (task.isImportant ? 1 : 0);
    }
    const insert = this.db.prepare('INSERT INTO tasks (description, isComplete, isImportant, todo_list_id) VALUES (@description, @isComplete, @isImportant, 1)');

    const insertList = this.db.transaction((tasks) => {
      for (let task of tasks) {
        insert.run(task.attributes());
      }
    });
    insertList(todoList.tasks);
  }
// Note: the code below now is replaced by updating actions in the TodoListController file
the code below now is replaced by updating actions in the TodoListController file
the code below now is replaced by updating actions in the TodoListController file
saveTodoList(todoList) {
    this.db.prepare('DELETE FROM tasks WHERE tasks.todo_list_id = 1').run();
    for (let task of todoList.tasks) {
      task.isComplete = (task.isComplete ? 1 : 0);
      task.isImportant = (task.isImportant ? 1 : 0);
    }
    const insert = this.db.prepare('INSERT INTO tasks (description, isComplete, isImportant, todo_list_id) VALUES (@description, @isComplete, @isImportant, 1)');
    const insertList = this.db.transaction((tasks) => {
      for (let task of tasks) {
        insert.run(task.attributes());
      }
    });
    insertList(todoList.tasks);
  }
saveTodoList ( todoList ) { this . db . prepare ( 'DELETE FROM tasks WHERE tasks.todo_list_id = 1' ) . run ( ) ; for ( let task of todoList . tasks ) { task . isComplete = ( task . isComplete ? 1 : 0 ) ; task . isImportant = ( task . isImportant ? 1 : 0 ) ; } const insert = this . db . prepare ( 'INSERT INTO tasks (description, isComplete, isImportant, todo_list_id) VALUES (@description, @isComplete, @isImportant, 1)' ) ; const insertList = this . db . transaction ( ( tasks ) => { for ( let task of tasks ) { insert . run ( task . attributes ( ) ) ; } } ) ; insertList ( todoList . tasks ) ; }
Note: the code below now is replaced by updating actions in the TodoListController file
Note : the code below now is replaced by updating actions in the TodoListController file