I use the ORM framework in TypeScript (TypeORM) and can set something using annotations (e.g. @entity (database: '')).
Can I get the parameter value from the annotation from a .env file or class with constants?
I have tried:
@entity(database: process.env.DATA_BASE_NAME) class UserEntity {...}
Without success = / Because at that moment my .env was not created yet = /
But it works fine
@entity(database: 'Users') class UserEntity { dotenv.config(); @(column: process.env.TABLE_USER_COL_ID_NAME, ...) private id: number; }
Any advice to solve this?
source share