🚧 🐘 setup TageEntity and relationship

This commit is contained in:
Ben Hesseldieck 2021-03-09 16:12:44 +01:00
parent e043e89f7f
commit 1231c4d670
3 changed files with 36 additions and 2 deletions

View file

@ -72,12 +72,13 @@ export interface IWebhookDb {
export interface IWorkflowBase extends IWorkflowBaseWorkflow {
id?: number | string;
}
export interface ITagDb {
id: number | string;
name: string;
createdAt: Date;
updatedAt: Date;
}

View file

@ -0,0 +1,23 @@
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ITagDb } from '../../Interfaces';
import { WorkflowEntity } from './WorkflowEntity';
@Entity()
export class TagEntity implements ITagDb {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true, length: 24 })
name: string;
@Column()
createdAt: Date;
@Column()
updatedAt: Date;
@ManyToMany(() => WorkflowEntity, workflowEntity => workflowEntity.tags)
workflows: WorkflowEntity[];
}

View file

@ -12,9 +12,15 @@ import {
import {
Column,
Entity,
JoinTable,
ManyToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
import {
TagEntity,
} from './TagEntity';
@Entity()
export class WorkflowEntity implements IWorkflowDb {
@ -52,4 +58,8 @@ export class WorkflowEntity implements IWorkflowDb {
nullable: true,
})
staticData?: IDataObject;
@ManyToMany(() => TagEntity, tagEntity => tagEntity.workflows)
@JoinTable({ name: "workflows_tags" })
tags: TagEntity[];
}