From f3818200495c75a043c87314172735819f621430 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Mon, 10 Feb 2025 11:36:57 +0400 Subject: [PATCH] added tag relation to project and product --- libs/common/src/modules/product/entities/product.entity.ts | 4 ++++ libs/common/src/modules/project/entities/project.entity.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/common/src/modules/product/entities/product.entity.ts b/libs/common/src/modules/product/entities/product.entity.ts index dd7a1e5..209b7b1 100644 --- a/libs/common/src/modules/product/entities/product.entity.ts +++ b/libs/common/src/modules/product/entities/product.entity.ts @@ -4,6 +4,7 @@ import { AbstractEntity } from '../../abstract/entities/abstract.entity'; import { DeviceEntity } from '../../device/entities'; import { TagModel } from '../../space-model'; import { TagEntity } from '../../space/entities/tag.entity'; +import { NewTagEntity } from '../../tag/entities'; @Entity({ name: 'product' }) export class ProductEntity extends AbstractEntity { @Column({ @@ -27,6 +28,9 @@ export class ProductEntity extends AbstractEntity { }) public prodType: string; + @OneToMany(() => NewTagEntity, (tag) => tag.product, { cascade: true }) + public newTags: NewTagEntity[]; + @OneToMany(() => TagModel, (tag) => tag.product) tagModels: TagModel[]; diff --git a/libs/common/src/modules/project/entities/project.entity.ts b/libs/common/src/modules/project/entities/project.entity.ts index ee6a2c5..62531dc 100644 --- a/libs/common/src/modules/project/entities/project.entity.ts +++ b/libs/common/src/modules/project/entities/project.entity.ts @@ -5,6 +5,7 @@ import { CommunityEntity } from '../../community/entities'; import { SpaceModelEntity } from '../../space-model'; import { UserEntity } from '../../user/entities'; import { InviteUserEntity } from '../../Invite-user/entities'; +import { NewTagEntity } from '../../tag/entities'; @Entity({ name: 'project' }) @Unique(['name']) @@ -36,6 +37,9 @@ export class ProjectEntity extends AbstractEntity { @OneToMany(() => InviteUserEntity, (inviteUser) => inviteUser.project) public invitedUsers: InviteUserEntity[]; + @OneToMany(() => NewTagEntity, (tag) => tag.project, { cascade: true }) + public tags: NewTagEntity[]; + constructor(partial: Partial) { super(); Object.assign(this, partial);