错误 [ExceptionHandler] 未找到 "Product" 的存储库。 Nest.js
ERROR [ExceptionHandler] No repository for "Product" was found. Nest.js
我正在尝试注册和迁移新实体 (Nest.js),但失败并显示以下错误文本:
ERROR [ExceptionHandler] No repository for "Product" was found. Looks like this entity is not registered in the current "default" connection?
product.entity.ts
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
@Entity()
export class Product {
@PrimaryGeneratedColumn()
id: number;
@Column()
title: string;
@Column()
image: string;
}
product.module.ts
import { Module } from '@nestjs/common';
import { ProductController } from './product.controller';
import { TypeOrmModule } from "@nestjs/typeorm";
import { Product } from "./product.entity";
@Module({
imports: [
TypeOrmModule.forFeature([Product])
],
controllers: [ProductController]
})
export class ProductModule {}
有什么想法吗?
您可以使用 auto load entities 功能来规避它。
(就像我在 discord 上说的)
我正在尝试注册和迁移新实体 (Nest.js),但失败并显示以下错误文本:
ERROR [ExceptionHandler] No repository for "Product" was found. Looks like this entity is not registered in the current "default" connection?
product.entity.ts
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
@Entity()
export class Product {
@PrimaryGeneratedColumn()
id: number;
@Column()
title: string;
@Column()
image: string;
}
product.module.ts
import { Module } from '@nestjs/common';
import { ProductController } from './product.controller';
import { TypeOrmModule } from "@nestjs/typeorm";
import { Product } from "./product.entity";
@Module({
imports: [
TypeOrmModule.forFeature([Product])
],
controllers: [ProductController]
})
export class ProductModule {}
有什么想法吗?
您可以使用 auto load entities 功能来规避它。 (就像我在 discord 上说的)