Model subtypes #1264
-
How would you go about model subtypes? I have Clients that can be of two types, with shared fields and type specific fields. Already made migrations for the 3 tables. I went thru all the forum posts in the Database section. The only related one that I could find didn't get into managing Model subtypes in Adonis. What should I do?:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There is no concept of sub types in Lucid. Infact, I have not seen them in majority of streamline ORMs. What you are after is relationships.
With relationships in place, The ORM output object will be as follows: {
clientId: '',
entityId: '',
client: {
type: '',
contract
}
} You are looking to fetch a merged flat list of attributes. The ORM is all about relationships and trees. |
Beta Was this translation helpful? Give feedback.
-
How would you handle a many-to-many relationship with these "clients"? Would you do a many-to-many with |
Beta Was this translation helpful? Give feedback.
There is no concept of sub types in Lucid. Infact, I have not seen them in majority of streamline ORMs. What you are after is relationships.
Residential Client → hasOne → Client
Stalal Client → hasOne → Client
With relationships in place, The ORM output object will be as follows:
You are looking to fetch a merged flat list of attributes. The ORM is all about relationships and trees.