pushObject to hasMany attribute


#1

Guys, in my event i have several bookings, and i’m trying to figure it out how can i push an booking to my event. I’m trying like this:

this.get('booking').save().then((data) => {
  let id    = this.get('event').get('id');
  let event = this.get('store').peekRecord('event', id);

  event.get('bookings').pushObject(data);
  event.save();
});

I follow the docs, but is not working. I’m receiving in the server:

{ data: 
   { _id: '5666fc9f6819aa9c0f0304c7',
     attributes: 
      { status: true,
        start: '2015-12-16T15:51:30.475Z',
        end: '2015-12-30T15:51:40.408Z',
        men: 60,
        women: 40,
        information: '1hr de open bar',
        meeting: 'Açaí beach bar',
        title: 'Evento um',
        hiw: null,
        tip: null },
     type: 'events' } }

As you can see. The bookings is not there.

Thanks.


#2

Having a similar issue trying to add and remove objects from a couple hasMany properties in my models. I’m using Ember 1.13.13 and Ember Data 1.13.15.