I am trying to register and migrate a new entity (Nest.js) but it fails with the following error text:
JavaScript
x
2
1
ERROR [ExceptionHandler] No repository for "Product" was found. Looks like this entity is not registered in the current "default" connection?
2
product.entity.ts
JavaScript
1
15
15
1
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
2
3
4
@Entity()
5
export class Product {
6
@PrimaryGeneratedColumn()
7
id: number;
8
9
@Column()
10
title: string;
11
12
@Column()
13
image: string;
14
}
15
product.module.ts
JavaScript
1
13
13
1
import { Module } from '@nestjs/common';
2
import { ProductController } from './product.controller';
3
import { TypeOrmModule } from "@nestjs/typeorm";
4
import { Product } from "./product.entity";
5
6
@Module({
7
imports: [
8
TypeOrmModule.forFeature([Product])
9
],
10
controllers: [ProductController]
11
})
12
export class ProductModule {}
13
Any ideas?
Advertisement
Answer
You could use the auto load entities feature to circumvent that. (like I said on discord)