# @codemeistre/typeorm-common

> Common TypeORM integrations.

Latest version **1.0.3** (published 2022-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @codemeistre/typeorm-common
pnpm add @codemeistre/typeorm-common
yarn add @codemeistre/typeorm-common
bun add @codemeistre/typeorm-common
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-10-22 |
| First published | 2022-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | CodeMeistre |
| Maintainers | foliveirafilho, codemeistre-bot, micalevisk |

## Links

- npm: https://www.npmjs.com/package/@codemeistre/typeorm-common
- Repository: https://github.com/codemeistre/shared
- Homepage: https://github.com/codemeistre/shared/tree/master/packages/typeorm-common
- Issues: https://github.com/codemeistre/shared/issues
- npm.io page: https://npm.io/package/@codemeistre/typeorm-common

## Dependencies (4)

- [typeorm](https://npm.io/package/typeorm.md) 0.3.10
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) 9.1.5
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) 9.1.5
- [@nestjs/typeorm](https://npm.io/package/@nestjs/typeorm.md) 9.0.1

## Recent versions

- 1.0.3 (latest) — 2022-10-22
- 1.0.2 — 2022-10-22
- 1.0.1 — 2022-10-22
- 1.0.0 — 2022-10-22

## README

# typeorm-common

Expose some useful TypeORM integrations.

## Installation

```bash

yarn add -E @codemeistre/typeorm-common

```

## Usage

### NestJs

As TypeORM ^0.3.0 do not support custom repositories via `@EntityRepository()`, [here's a workaround](https://gist.github.com/anchan828/9e569f076e7bc18daf21c652f7c3d012) 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.

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

#### `CustomRepositoryModule.forFeature([Repositories])`

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

```ts
@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!_**.

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

---
_Source: https://npm.io/package/@codemeistre/typeorm-common · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
