You could do this in the Task class instead of adding from the Projects class. As long as you've got the project id when you're creating the Task you can find the associated project and push the new task into the project.tasks array when you create the task.