私は2つのモデルを持っています:
イベント.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週間立ち往生しています。
組み込みオプションの使用、手動での更新など、すでにいくつかのことを試しましたが、何も機能しません。
助けてくれてありがとう!