mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
refactor(nestjs): import module
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { ImportFilePreviewPOJO } from './interfaces';
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { IImportFileCommitedEventPayload, ImportFilePreviewPOJO } from './interfaces';
|
||||
import { ImportFileProcess } from './ImportFileProcess';
|
||||
import { ImportAls } from './ImportALS';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { events } from '@/common/events/events';
|
||||
import { TENANCY_DB_CONNECTION } from '../Tenancy/TenancyDB/TenancyDB.constants';
|
||||
|
||||
@Injectable()
|
||||
export class ImportFileProcessCommit {
|
||||
@@ -11,6 +13,9 @@ export class ImportFileProcessCommit {
|
||||
private readonly importFile: ImportFileProcess,
|
||||
private readonly importAls: ImportAls,
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
|
||||
@Inject(TENANCY_DB_CONNECTION)
|
||||
private readonly tenantKnex: () => Knex,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -30,8 +35,9 @@ export class ImportFileProcessCommit {
|
||||
* @returns {Promise<ImportFilePreviewPOJO>}
|
||||
*/
|
||||
public async commitAlsRun(importId: string): Promise<ImportFilePreviewPOJO> {
|
||||
const trx = await knex.transaction({ isolationLevel: 'read uncommitted' });
|
||||
|
||||
const trx = await this.tenantKnex().transaction({
|
||||
isolationLevel: 'read uncommitted',
|
||||
});
|
||||
const meta = await this.importFile.import(importId, trx);
|
||||
|
||||
// Commit the successed transaction.
|
||||
|
||||
Reference in New Issue
Block a user