mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Move tag collection into repository (no-changelog) (#6860)
* refactor(core): Move tag collection into repository * Fix tests * Address feedback * Fix missing spot
This commit is contained in:
@@ -35,6 +35,8 @@ import type { ExecutionData } from '@db/entities/ExecutionData';
|
||||
import { generateNanoId } from '@db/utils/generators';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import { VariablesService } from '@/environments/variables/variables.service';
|
||||
import { TagRepository } from '@/databases/repositories';
|
||||
import { separate } from '@/utils';
|
||||
|
||||
export type TestDBType = 'postgres' | 'mysql';
|
||||
|
||||
@@ -113,7 +115,13 @@ export async function terminate() {
|
||||
* Truncate specific DB tables in a test DB.
|
||||
*/
|
||||
export async function truncate(collections: CollectionName[]) {
|
||||
for (const collection of collections) {
|
||||
const [tag, rest] = separate(collections, (c) => c === 'Tag');
|
||||
|
||||
if (tag) {
|
||||
await Container.get(TagRepository).delete({});
|
||||
}
|
||||
|
||||
for (const collection of rest) {
|
||||
await Db.collections[collection].delete({});
|
||||
}
|
||||
}
|
||||
@@ -384,7 +392,7 @@ export async function createWaitingExecution(workflow: WorkflowEntity) {
|
||||
export async function createTag(attributes: Partial<TagEntity> = {}) {
|
||||
const { name } = attributes;
|
||||
|
||||
return Db.collections.Tag.save({
|
||||
return Container.get(TagRepository).save({
|
||||
id: generateNanoId(),
|
||||
name: name ?? randomName(),
|
||||
...attributes,
|
||||
|
||||
Reference in New Issue
Block a user