javascript - Updating already existing event with relationship when a booking is saved in Ember -


i have 2 models:

event.js:

export default model.extend({   checked       : attr({ defaultvalue: false }),   isactive      : attr(),   createdat     : attr(),   updatedat     : attr(),   start         : attr(),   end           : attr(),   menprice      : attr(),   womenprice    : attr(),   information   : attr(),   meetingpoint  : attr(),   title         : attr(),   hiw           : attr(),   tip           : attr(),   bookings      : hasmany('booking', { async: true}) }); 

and booking.js:

export default model.extend({   checked       : attr({ defaultvalue: false }),   isactive      : attr(),   createdat     : attr(),   updatedat     : attr(),   participants  : attr(),   email         : attr(),   locale        : attr(),   name          : attr(),   observation   : attr(),   phonenumber   : attr(),   event         : belongsto('event') }); 

and create relationship referring bookings in events, can't figure out how!

how works: when create event in admin dashboard, there isn't bookings refer, happens in site, when user makes reservation.

i using code save booking (reservation) , refer owner event:

let booking =  this.get('store').createrecord('booking', {     event: this.get('event') });  booking.save(); 

and it's working. that's how booking looks like:

this booking json:

{     "_id": {         "$oid": "56beb58da080cf2c2d46065b"     },     "relationships": {         "event": {             "data": {                 "id": "56baa0cdd79cd63c7a0f0065",                 "type": "events"             }         }     },     "type": "bookings",     "attributes": {         "created-at": {             "$date": "2016-02-13t04:48:13.489z"         },         "gender": "null",         "hostel": "null",         "phone-number": "918918918118",         "observation": "obs",         "name": "marcelo",         "locale": "es",         "email": "marcelo@pubcrawlsp.com",         "participants": 10,         "value": 0,         "is-active": false,         "vip": []     },     "__v": 0 } 

as can see, relationship working booking.

now need opposite, mean.. update event booking inside .. can't, can't figure out how! i'm stuck on @ least 3 weeks.

i tried several things, including using embedded option, updating manually, nothing works.

i appreciate help!

maybe understand question wrongly there point in saving event bookings ?

i mean 1 many relationship one, bookings have eventid pointing event related event doesn't hold reference bookings. saving changes on event should automatically reflected on bookings referencing it.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -