我知道有很多关于这个主题的帖子。我真的很难理解我到底想做什么来解决这个问题。使用 Postman,当我尝试命中路线时,出现以下错误:
ERROR [ExceptionsHandler] No metadata for "OrganizationsRepository" was found.
EntityMetadataNotFoundError: No metadata for "OrganizationsRepository" was found.
这是我的代码的样子
// app.module.ts
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'postgres',
host: 'localhost',
port: 5432,
database: 'my-database',
username: 'postgres',
password: 'password',
autoLoadEntities: true,
synchronize: true,
}),
ConfigModule.forRoot({
isGlobal: true,
}),
OrganizationsModule,
],
controllers: [],
providers: [],
exports: [],
})
export class AppModule {}
// organizations.repository.ts
@EntityRepository(Organization). // this is showing as deprecated
export class OrganizationsRepository extends Repository<Organization> {
...
}
// organization.entity.ts
@Entity({ name: 'organizations' })
export class Organization extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
name: string;
...
我相信我需要创建一个新的DataSource
——或者更具体地说,自定义存储库?
我一直使用上面的方法从我的数据库中读取数据,没有任何问题。现在突然间我收到此错误,并且我不确定如何在我的代码中解决。