I am accessing an API that includes data from a many-to-many relationship table as JSON:API relationship meta data. This is defined in the JSON:API specification at JSON:API — Latest Specification (v1.0).
I am using Ember 3.18.1 with Ember Data 3.18.0. Both models have @hasMany. The route retrieves the data as follows.
model(params) {
return this.store.findRecord("table1", params.table1_id, {
include : "table2s"
});
}
I have read the Ember Metadata documentation (Handling Metadata - Ember Data - Ember Guides), but I see nothing about reading metadata for individual relationships. How can this be done in Ember Data?
Below is an example of the JSON.
{
"jsonapi": {
"version": "1.0"
},
"data": {
"id": "1",
"type": "table1"
"attributes": {
...
},
"relationships": {
"table2s": {
"data": [
{
"id": "11",
"type": "table2",
"meta": {
"order": 1
}
},
{
"id": "12",
"type": "table2",
"meta": {
"order": 2
}
}
]
}
}
},
"included": [
{
"id": "11",
"type": "table2",
"attributes": {
...
}
},
{
"id": "12",
"type": "table2",
"attributes": {
...
}
}
]
}