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 https://jsonapi.org/format/#document-resource-identifier-objects.
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 (https://guides.emberjs.com/release/models/handling-metadata/), 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": {
...
}
}
]
}
1 post - 1 participant