How to keep belongsTo and hasMany Async?


#1

So basically I have a project model which has many todos 0…n:

App.Project = DS.Model.extend({
  title: DS.attr('string'),
  date: DS.attr('date', {defaultValue: null}),
  tag: DS.attr('string', {defaultValue: null}),
  todos: DS.hasMany('todo', {async: true})
});

and a todo model which belongs to a project 0…1:

App.Todo = DS.Model.extend({
  title: DS.attr('string'),
  date: DS.attr('date', {defaultValue: null}),
  project: DS.belongsTo('project', {async: true})
});

So I can simply get which project todo belongs to :

{{#each todo in model}}
     {{todo.title}}
     {{todo.project.title}}
{{/each}}

and set which project todo belongs to :

var todo = this.store.createRecord('todo');
this.store.find('project', 1).then(function(project){
  todo.set('project', project);
  todo.save();
});

But how do we keep the other side ( the project model ) to have the todo in it hasMany attr?

Do we need to set in the project model, or is there any method in keeping them async?