
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
nestjs-typeorm-unit-of-work
Advanced tools
Package for typeorm, which helps to realize "unit of work" pattern
Package for typeorm, which helps to realize "unit of work" pattern. Monorepo containing Nest module and example
npm i nestjs-typeorm-unit-of-work
@Module({
imports: [
TypeOrmModule.forRootAsync({
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: configService.getOrThrow('DB_HOST'),
port: Number(configService.getOrThrow('DB_PORT')),
username: configService.getOrThrow('DB_USER'),
password: configService.get('DB_PASSWORD'),
database: configService.getOrThrow('DB_DATABASE'),
entities: [EmployeeEntity],
}),
}),
TypeormUnitOfWorkModule.forRootAsync({
inject: [getDataSourceToken()],
useFactory: (dataSource: DataSource): ITypeormUnitOfWorkModuleOptions => ({
dataSource,
}),
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
@Injectable()
export class AppService {
constructor(
@InjectTypeormUnitOfWork() private readonly unitOfWork: UnitOfWork,
) {
}
async example (): Promise<number> {
await this.unitOfWork.start();
const employeeRepository = await this.unitOfWork.getRepository<EmployeeEntity>(EmployeeEntity);
const {
isSuccess,
data: employeeId,
} = await this.unitOfWork.commit<number>(
async () => {
const employee = await employeeRepository.save({
firstName: 'firstName',
lastName: 'lastName',
yearlyIncomes: 100,
});
await employeeRepository.update(employee.id, {
yearlyIncomes: employee.yearlyIncomes + 100,
})
return employee.id;
}
)
return employeeId;
}
}
FAQs
Package for typeorm, which helps to realize "unit of work" pattern
The npm package nestjs-typeorm-unit-of-work receives a total of 0 weekly downloads. As such, nestjs-typeorm-unit-of-work popularity was classified as not popular.
We found that nestjs-typeorm-unit-of-work demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.