# @onivoro/server-typeorm-postgres

> TypeORM PostgreSQL integration for the Ivim monorepo: a NestJS dynamic module, enhanced repository base classes, and a Redshift repository.

Latest version **24.39.0** (published 2026-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @onivoro/server-typeorm-postgres
pnpm add @onivoro/server-typeorm-postgres
yarn add @onivoro/server-typeorm-postgres
bun add @onivoro/server-typeorm-postgres
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 24.39.0 |
| Published | 2026-09-23 |
| First published | 2023-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 54.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | icedlee337 |

## Links

- npm: https://www.npmjs.com/package/@onivoro/server-typeorm-postgres
- Repository: https://github.com/onivoro/monorepo
- Homepage: https://github.com/onivoro/monorepo#readme
- Issues: https://github.com/onivoro/monorepo/issues
- npm.io page: https://npm.io/package/@onivoro/server-typeorm-postgres

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0
- [@onivoro/server-typeorm-common](https://npm.io/package/@onivoro/server-typeorm-common.md) 24.39.0

## Recent versions

- 24.39.0 (latest) — 2026-09-23
- 24.38.2 — 2026-05-15
- 24.38.1 — 2026-05-12
- 24.38.0 — 2026-05-10
- 24.37.0 — 2026-05-10
- 24.36.0 — 2026-05-09
- 24.35.4 — 2026-05-09
- 24.35.3 — 2026-05-09
- 24.35.2 — 2026-04-27
- 24.35.1 — 2026-04-24
- 24.35.0 — 2026-04-23
- 24.34.2 — 2026-04-22
- 24.34.1 — 2026-04-22
- 24.34.0 — 2026-04-22
- 24.33.21 — 2026-04-19
- … 132 more at https://npm.io/package/@onivoro/server-typeorm-postgres/versions

## README

# @onivoro/server-typeorm-postgres

TypeORM PostgreSQL integration for the Ivim monorepo: a NestJS dynamic module, enhanced repository base classes, and a Redshift repository.

Shared types and helpers (`IPagedData`, `IPageParams`, `manyToOneRelationOptions`, `removeFalseyKeys`, `getSkip`, `getPagingKey`) live in [`@onivoro/server-typeorm-common`](../typeorm-common/) and are re-exported from this package for convenience.

## Module setup

```typescript
import { ServerTypeormPostgresModule } from '@onivoro/server-typeorm-postgres';

@Module({
  imports: [
    ServerTypeormPostgresModule.configure(
      [UserRepository],           // injectables
      [User],                     // entities
      {
        host: 'localhost',
        port: '5432',
        username: 'postgres',
        password: 'password',
        database: 'myapp',
        ca: process.env.DB_CA,    // optional SSL CA
        synchronize: false,        // never true in production
        logging: false,
        schema: 'public',          // optional
      },
      'default',                  // connection name (default: 'default')
    ),
  ],
})
export class AppModule {}
```

The module caches data sources by name, uses `SnakeNamingStrategy`, and destroys open pools on application shutdown.

## Repositories

### `TypeOrmRepository<TEntity>`

Thin wrapper over TypeORM's `Repository` with convenience methods:

```typescript
@Injectable()
export class UserRepository extends TypeOrmRepository<User> {
  constructor(entityManager: EntityManager) {
    super(User, entityManager);
  }
}

// Methods: getOne, getMany, getManyAndCount, postOne (insert + returning),
//          postMany, patch (update), put (save), delete, softDelete, head,
//          query, queryAndMap, forTransaction, buildWhereILike.
// `getOne` throws if the result set has more than one row.
```

### `TypeOrmPagingRepository<TEntity, TParams>`

Abstract subclass for paginated queries. Subclasses implement `getPage(pageParams, params)` and can use the inherited `getSkip`, `getPagingKey`, `removeFalseyKeys` helpers.

### `RedshiftRepository<TEntity>`

Specialization of `TypeOrmRepository` for Amazon Redshift. Overrides `getMany`, `getOne`, `delete`, `patch`, `postOne`, `postMany` to emit raw SQL compatible with Redshift's quirks (e.g. `JSON_PARSE()` wrapping for `jsonb` columns). `put`, `forTransaction`, `getManyAndCount`, `postManyWithoutReturn`, and `head` throw `NotImplementedException` — Redshift can't meaningfully support them.

## License

MIT

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