Polymorphic hasMany relationship in js-data

157 Views Asked by At

is it possible to define a polymorphic hasMany relationship in js-data?

For example, a User has many animals, where an Animal can be a Cat or a Dog (ES6/TS class Dog extends Animal). If I request user.animals, I should receive a collection of cats and dogs, which may have their own custom properties.

I can't figure out from the docs how to setup my resource. Ember Data supports this.

1

There are 1 best solutions below

4
On

According to the doc, its possible with js-data 2.0, http://www.js-data.io/docs/relations

Check these js-data hasMany example, would be quick hints for solve your problem

http://www.js-data.io/docs/examples#relations