-
The manual shows how to use Single Tabel Inheritance using the static fields() method and using the spread operator calling super.fields(). But what when I am using decorators? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
If you just want to have a simple extend then look there: #325 If you use types then yes i should have included an decorator example in the docs. class Animal extends Model {
static entity = 'animals'
@Attr(null) declare id: number | null
@Attr('animal') declare type: string
static types() {
return {
animal: Animal,
dog: Dog,
}
}
}
class Dog extends Animal {
static entity = 'dogs'
static baseEntity = 'animals'
static fields() {
return {
...super.schemas[super.entity],
}
}
@Attr('dog') declare type
@Attr('terrier') declare race: string
} |
Beta Was this translation helpful? Give feedback.
-
Thanks, I am still facing issues. I have separated the models into their own files. You mentioned that there could be circular reference error - but the link in the manual does not work. How should this be handled? Maybe there are some more issues? Sandbox: https://codesandbox.io/s/single-table-inheritance-demo-21rukn?file=/src/App.vue |
Beta Was this translation helpful? Give feedback.
Thanks, I am still facing issues. I have separated the models into their own files. You mentioned that there could be circular reference error - but the link in the manual does not work. How should this be handled? Maybe there are some more issues?
Sandbox: https://codesandbox.io/s/single-table-inheritance-demo-21rukn?file=/src/App.vue