0
私はレストランのメニューを表示するためにemberアプリケーションを書いています。データは多くのメニューセクションを有するレストランとして編成され、それ自体は多くのアイテムを有する。ネストされた関係を使用して包含
私のルートでは、findRecordを使用して、トップレベルのレストランレコードをインクルードセットでロードして、セクションとアイテムを含めます。私は私のルートで
// restaurant.js
export default DS.Model.extend({
title: DS.attr(),
contactNumber: DS.attr(),
restaurantAddress: DS.attr(),
deliveryCost: DS.attr(),
minimumOrder: DS.attr(),
menuSections: DS.hasMany('menu-section')
});
// menu-section.js
export default DS.Model.extend({
title: DS.attr(),
description: DS.attr(),
restaurantDetails: DS.belongsTo('restaurant'),
items: DS.hasMany('menu-item')
});
// menu-item.js
export default DS.Model.extend({
foodName: DS.attr(),
price: DS.attr(),
isVegetarian: DS.attr(),
isHot: DS.attr(),
containsNuts: DS.attr(),
menuSection: DS.belongsTo('menu-section')
});
::私は、適切な関係でモデルを定義残り火で
{
"links": {
"up": "http://localhost/api/restaurants",
"self": "http://localhost/api/restaurants/0b27fd96-90e8-11e7-81c2-08002787e7fb"
},
"data": {
"type": "restaurant",
"id": "0b27fd96-90e8-11e7-81c2-08002787e7fb",
"attributes": {
"title": "Made-Up Foodery",
"contact-number": "+1-555-1234",
"restaurant-address": "Made-up, address F4K 3ED",
"minimum-order": 500,
"delivery-cost": 250
},
"relationships": {
"menu-sections": {
"links": {
"related": "http://localhost/restaurants/0b27fd96-90e8-11e7-81c2-08002787e7fb/menu-sections"
},
"data": [
{
"type": "menu-section",
"id": "23760716-1b75-4880-bae4-a6daaef3fc98"
}
]
}
}
},
"included": [
{
"type": "menu-section",
"id": "23760716-1b75-4880-bae4-a6daaef3fc98",
"attributes": {
"title": "Test Section",
"description": "This is a test section."
},
"relationships": {
"menu-items": {
"links": {
"related": "http://localhost/menu-sections/23760716-1b75-4880-bae4-a6daaef3fc98/menu-items"
},
"data": [
{
"type": "menu-item",
"id": "a62e2ae0-326b-4838-b5ba-ffa102fcafb1"
}
]
}
},
"links": {
"self": "http://localhost/menu-sections/23760716-1b75-4880-bae4-a6daaef3fc98"
}
},
{
"type": "menu-item",
"id": "a62e2ae0-326b-4838-b5ba-ffa102fcafb1",
"attributes": {
"food-name": "Test Food",
"price": 350,
"is-hot": true,
"is-vegetarian": false,
"contains-nuts": false
},
"links": {
"self": "http://localhost/menu-items/a62e2ae0-326b-4838-b5ba-ffa102fcafb1"
}
}
]
}
:
let restaurant = this.get('store').findRecord('restaurant', '0b27fd96-90e8-11e7-81c2-08002787e7fb', {include: 'menuSections,menuSections.items'});
しかし限り私ができるように、サーバーには、以下のJSONAPIを生成しますメニューセクションのオブジェクトがロードされている間は、メニュー項目はロードされていません。
私の研究からわかるように、サーバーから発行されたJSONAPIは正しいものです。
私は何か間違っているのですか、これは単にember-dataによってサポートされていませんか?