Open jannishuebl opened 6 years ago
At some point I think we should have built-in support, but right now there are workarounds. Something like:
class Person extends ApplicationRecord {
static jsonapiType = 'people'
visas = hasMany()
mastercards = hasMany()
get creditCards() {
return this.visas.concat(this.mastercards)
}
}
// response will include credit_cards association containing types 'visa' and 'mastercard'
let { data } = await Person.includes('credit_cards')
data.visas // just visa credit cards
data.creditCards // all types of credit cards
Would love to see more built-in support in the future.
Hi,
I am using JSORM to construct a test script. I want to check on the roadmap of built in support for polymorphic resource fix.
@uday160386 possibly in Q4 this year, but the snippet above should get you running right now. Nothing really prevents polymorphic relationships, we can just add better sugar.
Hello,
In my current application I would like to have a Model, which has an polymorphic association. Is is covered by json:api spec. At least I could not find something that prohibits us to do something like that.
Could jsorm support something like that?
eg:
for sure the example does not make to much sense, but it should point out what I mean.
Cheers,
Jannis