@codemeistre/typeorm-common
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

typeorm-common

Expose some useful TypeORM integrations.

Installation

yarn add -E @codemeistre/typeorm-common

Usage

NestJs

As TypeORM ^0.3.0 do not support custom repositories via @EntityRepository(), here's a workaround to continue using the same API. This package is based on it.

@CustomRepository(Entity)

Similarly to @EntityRepository(), it should be used in the repository class.

@CustomRepository(FooEntity)
export class FooRepository extends Repository<FooEntity> {}

CustomRepositoryModule.forFeature([Repositories])

Similarly to @TypeOrmModule.forFeature(), it should be used in the resource module.

@Module({
  imports: [CustomRepositoryModule.forFeature([FooRepository])],
  exports: [CustomRepositoryModule],
})
export class FooModule {}

IMPORTANT: As we are not using TypeORmModule.forFeature(), we must provide the entities manually in entities when starting the TypeOrmModule, so autoLoadEntities won't work!.

@Module({
  imports: [
    TypeOrmModule.forRoot({
      entities: [FooEntity],
      // ...
    }),
  ],
})
export class DatabaseModule {}

Readme

Keywords

none

Package Sidebar

Install

npm i @codemeistre/typeorm-common

Weekly Downloads

8

Version

1.0.3

License

MIT

Unpacked Size

6.32 kB

Total Files

8

Last publish

Collaborators

  • foliveirafilho
  • codemeistre-bot
  • micalevisk