NestJS EntityMetadataNotFoundError: No metadata for "Repository" was found

Viewed 1493

I understand there are many posts about this topic. I am really struggling to understand what in the heck I am attempting to do to resolve the issue. Using Postman, when I attempt to hit a route, I am getting the following error:

ERROR [ExceptionsHandler] No metadata for "OrganizationsRepository" was found.
EntityMetadataNotFoundError: No metadata for "OrganizationsRepository" was found.

Here is what my code looks like

// 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;
...

I believe I need to create a new DataSource -- or more specifically, a custom repository?

I've always used the above to read from my database without issue. Now all of the sudden I am getting this error and I'm not sure how to resolve within the code I have.

0 Answers
Related