refactor(core): Move typeorm operators from various sources into repositories (no-changelog) (#8174)
Follow-up to: #8165
This commit is contained in:
@@ -17,6 +17,7 @@ import { isStringArray } from '@/utils';
|
||||
import config from '@/config';
|
||||
import { WorkflowEntity } from '../entities/WorkflowEntity';
|
||||
import { SharedWorkflow } from '../entities/SharedWorkflow';
|
||||
import { WebhookEntity } from '../entities/WebhookEntity';
|
||||
|
||||
@Service()
|
||||
export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||
@@ -183,4 +184,18 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||
where: { name: Like(`${workflowName}%`) },
|
||||
});
|
||||
}
|
||||
|
||||
async findIn(workflowIds: string[]) {
|
||||
return this.find({
|
||||
select: ['id', 'name'],
|
||||
where: { id: In(workflowIds) },
|
||||
});
|
||||
}
|
||||
|
||||
async findWebhookBasedActiveWorkflows() {
|
||||
return this.createQueryBuilder('workflow')
|
||||
.select('DISTINCT workflow.id, workflow.name')
|
||||
.innerJoin(WebhookEntity, 'webhook_entity', 'workflow.id = webhook_entity.workflowId')
|
||||
.execute() as Promise<Array<{ id: string; name: string }>>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user