尝试创建一对多关系时,“未找到实体的元数据”。

时间:2020-10-13 09:32:08

标签: nestjs typeorm

当我遇到以下错误时,我试图在名为UserUser_Mates的表之间创建一对多关系:

Error: Entity metadata for User#Mates was not found. Check if you specified a correct entity object and if it's connected in the connection options.

为调试该错误,我删除了该模块及其所有内容,直到只剩下初始模块为止。

现在项目中没有与User_Mate相关的文件或任何东西。 Vs code search

但是问题仍然存在。是否有人,现在可能导致此问题的原因。当我在Typeorm中加载时(我正在使用NestJS),我的主模块如下所示。

import { Module } from '@nestjs/common'
import { UserModule } from './user/user.module'
import { TypeOrmModule } from '@nestjs/typeorm'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { User } from './user/user.entity'

@Module({
  imports: [
    ConfigModule.forRoot(),
    UserModule,
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        type: 'postgres',
        host: configService.get('DB_HOST'),
        port: configService.get('DB_PORT'),
        username: configService.get('DB_USER'),
        password: configService.get('DB_PASSWORD'),
        database: configService.get('DB_DATABASE'),
        entities: [User],
        synchronize: true,
        ssl: {
          rejectUnauthorized: false,
        },
        //
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

它不应以任何方式加载。

这是一个错误吗?

0 个答案:

没有答案
相关问题