First, thankks a lot everybody for the answers and the very interesting explanations that I'm still trying to fully grasp ^^
My issue is related to all that but was indeed not that... it seems way more complicated... let me give you some details. It's kind of linked with Adonisjs/Lucid ORM so... I'll try to take shome shortcuts.... I hope it'll be clear
I have 5 different tables, that gives me 5 models.
If I write it kind of Adonis style, all my models will be like this :
export default class Modules extends BaseModel {
@column()
declare id: UUID
#column()
declare version: boolean
async getModules() {
}
static async getModules() {
}
}
export default class Projects extends BaseModel {
}
The thing is, my 5 tables will have 4 or 5 field in common, and some logic (around hundred lines) fully in common, to deal with a "version" systems amongst the modules and projects (long story to explain this architecture ^^")
For the fields, it's easy : I can just create an "intermediate model", called like VerisonedModel that inherit from base models, my 5 tables then inherit from VersionedModel
The problem comes when I want to "unify" the logic of the 5 tables in one.....
basic exemple :
const module = await db.query<Module>().from("modules").first()
const otherWay = await Module.query().first()
module.version = 12
module.save()
But, when I want to make it generic... something like that :
const module = await db.query<T>().from("modules").first()
Event calling a function with <Module>, it doesn't recognize any field :/
Since I know for sure that the type is "fine", I tried to take it in const module: any... everything works except the module.save() doesn't exist......