createRecord with many-to-many relationship


#1

How do I store.createRecord() with many-to-many relationships?

This is my Room model:

App.Room = DS.Model.extend({
  name         : DS.attr(),
  users: DS.hasMany('user',{async:true})
});

This is my User model:

App.User = DS.Model.extend({
  name         : DS.attr(),
  email        : DS.attr(),
  rooms: DS.hasMany('room',{async:true})
});

The User and the Room have a many-to-many relationship. When creating a record I use this:

var data =   {name: 'tbd', email: 'name@domain.com', rooms: [this.model.room.id] }
var record = this.store.createRecord('user', data);

However there is no relationship set.

(BTW I am using DS.RESTSerializer.)

Any ideas?