Im using typeorm with nestjs and postgreSql and trying to load the entities via the datasource options object which gets passed in the useFactory async function inside the typeorm module like
@Module({
imports: [TypeOrmModule.forRootAsync({ useFactory: () => (datasourceOptions) })],
})
this dataSourceOptions obejct is in a separate file containing the key value pairs of options and values repsectively. i wanted to pass typeorm to check and recognize the entities via the glob pattern
entities: [
join(__dirname, "../**/*entity{.ts,.js}")
],
like this , i have tried to test it with different patterns still i cant get it to work and i remember it used to work earlier with these patterns automatically registering the entities , now for a workaround i manually put in the entities instead of the pattern . how do i solve it so that all the entities get regitered without me having to entering the entity names manually one by one like
entities: [User, Conversation,Room, ],
i tried using different glob patterns and even the verified ones which used to work earlier but none are working right now , i dont know if thats because of some recent changes in the typeorm datasource options .
2
Answers
I rolled back to 0.3.11 and it worked.
The problem is related to the paths in Windows:
https://github.com/typeorm/typeorm/issues/9766
It seems that the problem lies in minor changes (0.3.12).
Install:
Not:
This work for me,
My folder structure: