0
I’m starting in the area so sorry if it’s something silly.
I started developing a server using Nestjs with Typeorm to connect to a Mysql database but am picking up the following error: 'No Repository for "User" was found. Looks like this Entity is not Registered in Current "default" Connection?'
Without using Typeorm I can run the server.
"User" is my entity.
app module.
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '',
database: 'meuserver',
entities: [`${__dirname}/**/*.entity{.ts,.js}`],
synchronize: true,
logging: true
}),
UserModule
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {
constructor(
private connection: Connection,
) { }
}
user module.
@Module({
imports: [
TypeOrmModule.forFeature([
User,
]),
],
providers: [
UserService,
],
controllers: [
UserController,
]
})
export class UserModule { }
user Entity.
@Entity('user')
export class User extends BaseEntity {
@Column()
name?: string;
@Column({ name: 'last_name' })
lastName?: string;
@Column({ default: false })
active?: boolean;
}
Could you tell me what I’m doing wrong?
Thank you in advance!
I adjusted it, but the error persists
– LittleFish
@Littlefish delete the 'dist' folder and run it again.
– Lucas Samuel
The problem was in my Typeormmodule configs. The path of entities was wrong. Now I’m picking up another error but it’s another topic. Thanks for the help
– LittleFish