mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8186)
Follow-up to: #8163
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import { flags } from '@oclif/command';
|
||||
import type { FindOptionsWhere } from 'typeorm';
|
||||
import type { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import { BaseCommand } from '../BaseCommand';
|
||||
import { WorkflowRepository } from '@db/repositories/workflow.repository';
|
||||
import Container from 'typedi';
|
||||
@@ -43,7 +40,6 @@ export class UpdateWorkflowCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
const updateQuery: QueryDeepPartialEntity<WorkflowEntity> = {};
|
||||
if (flags.active === undefined) {
|
||||
console.info('No update flag like "--active=true" has been set!');
|
||||
return;
|
||||
@@ -54,18 +50,16 @@ export class UpdateWorkflowCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
updateQuery.active = flags.active === 'true';
|
||||
const newState = flags.active === 'true';
|
||||
|
||||
const findQuery: FindOptionsWhere<WorkflowEntity> = {};
|
||||
if (flags.id) {
|
||||
this.logger.info(`Deactivating workflow with ID: ${flags.id}`);
|
||||
findQuery.id = flags.id;
|
||||
await Container.get(WorkflowRepository).updateActiveState(flags.id, newState);
|
||||
} else {
|
||||
this.logger.info('Deactivating all workflows');
|
||||
findQuery.active = true;
|
||||
await Container.get(WorkflowRepository).deactivateAll();
|
||||
}
|
||||
|
||||
await Container.get(WorkflowRepository).update(findQuery, updateQuery);
|
||||
this.logger.info('Done');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user