Answer the question
In order to leave comments, you need to log in
How to change tables dynamically in the database (model)?
Hello.
It is necessary to add several directories located in different postgres tables in the application admin panel.
Table properties are of the same type
"Id", "name_ru", "description".
Models Table1, Table2, etc. are created for each of the tables.
Do I need to make a separate CRUD controller with the same functionality for each of the models, or can I make one CrudController { constructor (model:string) and substitute the model name into the methods there?
What is the general practice?
Answer the question
In order to leave comments, you need to log in
class CRUD {
repository = null;
constructor(selectedRepository){
this.repository = selectedRepository;
}
someCRUDmethod(){
return this.repository.getSome();
}
}
class Current extends CRUD{
constructor(repo){
super(repo);
}
}
export default new Current(someRepo);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question