mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Update workflowRepository.getMany to use query builder (no-changelog) (#13207)
This commit is contained in:
@@ -2,6 +2,7 @@ import { Container } from '@n8n/di';
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
|
||||
import type { TagEntity } from '@/databases/entities/tag-entity';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { TagRepository } from '@/databases/repositories/tag.repository';
|
||||
import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository';
|
||||
import { generateNanoId } from '@/databases/utils/generators';
|
||||
@@ -25,3 +26,27 @@ export async function createTag(attributes: Partial<TagEntity> = {}, workflow?:
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
export async function assignTagToWorkflow(tag: TagEntity, workflow: WorkflowEntity) {
|
||||
const mappingRepository = Container.get(WorkflowTagMappingRepository);
|
||||
|
||||
// Check if mapping already exists
|
||||
const existingMapping = await mappingRepository.findOne({
|
||||
where: {
|
||||
tagId: tag.id,
|
||||
workflowId: workflow.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingMapping) {
|
||||
return existingMapping;
|
||||
}
|
||||
|
||||
// Create new mapping
|
||||
const mapping = mappingRepository.create({
|
||||
tagId: tag.id,
|
||||
workflowId: workflow.id,
|
||||
});
|
||||
|
||||
return await mappingRepository.save(mapping);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user