Suppose I make query in my route
RSVP.hash({
topics: this.get('store').query('topic', {'filter': data})
})
And back-end response jsonapi
which contain two model together:
"data": [{
"type": "topic",
"id": "1",
"attributes": {
"title": "JSON:API!"
}
"type": "filter",
"id": "1",
"attributes": {
"title": "JSON:API!"
}
]
NOTE: filter
don't have any relations with topic
and Data goes to ember store in a right way.
REASON: filter
- is a some metadata which already exist in back-end during quering topic
and quite ’costly’ make additional query like this.get('store').query('filter', {'filter': data})
.
QUESTION How I can recognize type
in result Ember, or how to deal with multiple types (without relations) in one response in general.
RSVP.hash({
topics: this.get('store').query('topic', {'filter': data})
}).then((res) => {
res.topics.forEach((i) => {
//detect which i type here
})
});
Aucun commentaire:
Enregistrer un commentaire