# How to keep belongsTo and hasMany linked?

**URL:** <https://discuss.emberjs.com/t/how-to-keep-belongsto-and-hasmany-linked/6816>\
**Category:** Uncategorized\
**Created:** [December 1, 2014, 1:49am UTC](https://discuss.emberjs.com/t/how-to-keep-belongsto-and-hasmany-linked/6816 "2014-12-01T01:49:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laipak](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/laipak/32/9821_2.png) [@Laipak](https://discuss.emberjs.com/u/Laipak)\
**Post date:** [December 1, 2014, 1:49am UTC](https://discuss.emberjs.com/t/how-to-keep-belongsto-and-hasmany-linked/6816/1 "2014-12-01T01:49:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rytis](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rytis/32/11242_2.png) [@rytis](https://discuss.emberjs.com/u/rytis)\
**Post date:** [September 7, 2015, 8:38am UTC](https://discuss.emberjs.com/t/how-to-keep-belongsto-and-hasmany-linked/6816/2 "2015-09-07T08:38:59Z")

</div>

Hi, did you ever solve this? I’m having the very same issue atm and am stuck clueless.
