我有两个模型:
事件.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})
});
和 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')
});
我想在我的活动中创建引用预订的关系,但我就是不知道怎么做!
工作原理:当我在管理仪表板中创建活动时,没有可参考的预订,这只发生在网站中,当用户进行预订时。
我正在使用此代码保存预订(预订)并参考所有者事件:
let booking = this.get('store').createRecord('booking', {
event: this.get('event')
});
booking.save();
它正在工作。这就是预订的样子:
这是我的预订 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
}
如您所见,该关系正在处理预订。
现在我需要相反的,我的意思是..用里面的预订更新活动..但我不能,我只是不知道怎么做!我至少坚持了3周。
我已经尝试了几件事,包括使用嵌入式选项、手动更新,但没有任何效果。
感谢您的帮助!