@nathapp/nestjs-typeorm
v4.1.0
Published
@nathapp/nestjs-typeorm
Readme
@nathapp/nestjs-typeorm
TypeORM integration for NestJS, including named connections, custom repository wiring, stored procedure helpers, and transaction propagation.
Transactions
Enable transaction support when registering a connection:
TypeOrmExModule.forRoot({
type: 'postgres',
url: process.env.DATABASE_URL,
entities: [UserEntity],
transaction: true,
});Inject TRANSACTION_MANAGER for the default connection or
getTypeOrmTransactionManagerToken(name) for a named connection. Repository
lookups through AbstractTypeOrmRepository, legacy @CustomRepository
repositories, BaseSpRepository.callQuery, @Transactional, and
TransactionService.withTransaction use the active runner for that
DataSource. Each connection has an independent context, including during nested
and concurrent work.
Stored procedure results
BaseSpRepository.callQuery preserves the driver result shape: PostgreSQL's
flat rows form one recordset, and MySQL/MariaDB remove a trailing status packet
only when the driver returned one. MySQL/MariaDB multiple recordsets remain
arrays of recordsets. The optional rename callback applies to each row, and the
objectifyForSignleRecord flag returns a single row as an object, multiple rows
as an array, and an empty result as {}. Calls without a recordset return []
by default.
