'How to generate entity files in NestJS and TypeORM

I come from Java background, we had tools to generate Java entity(DTOs, DAOs, JPAs, etc ...) files from the database directly, am working now on NestJS project and using TypeORM, I have my tables ~ 30 table implmented on MySQL, is there away to generate the entity files



Solution 1:[1]

What you are asking for is generally a Database First Approach to ORM, TypeORM does not support that natively AFAIK.

My best suggestion would be to implement a JSON to TS model and then map the required columns with TypeORM decorators. That will be your best bet.

For now, you can implement independent tables and then go along with other tables. I know its a long process. But modern ORMs are made to work with Entity first method.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rohit Gupta