cleaned space entities

This commit is contained in:
hannathkadher
2024-12-24 08:43:25 +04:00
parent 97b53bf417
commit 1e47fffc0a
12 changed files with 106 additions and 20 deletions
@@ -1,9 +1,17 @@
import { Column, Entity, JoinColumn, ManyToOne, Unique } from 'typeorm';
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
Unique,
} from 'typeorm';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { TagModelDto } from '../dtos/tag-model.dto';
import { SpaceModelEntity } from './space-model.entity';
import { SubspaceModelEntity } from './subspace-model';
import { ProductEntity } from '../../product/entities';
import { TagEntity } from '../../space/entities/tag.entity';
@Entity({ name: 'tag_model' })
@Unique(['tag', 'product', 'spaceModel', 'subspaceModel'])
@@ -18,13 +26,13 @@ export class TagModel extends AbstractEntity<TagModelDto> {
product: ProductEntity;
@ManyToOne(() => SpaceModelEntity, (space) => space.tags, { nullable: true })
@JoinColumn({ name: 'space_id' })
@JoinColumn({ name: 'space_model_id' })
spaceModel: SpaceModelEntity;
@ManyToOne(() => SubspaceModelEntity, (subspace) => subspace.tags, {
nullable: true,
})
@JoinColumn({ name: 'subspace_id' })
@JoinColumn({ name: 'subspace_model_id' })
subspaceModel: SubspaceModelEntity;
@Column({
@@ -32,4 +40,7 @@ export class TagModel extends AbstractEntity<TagModelDto> {
default: false,
})
public disabled: boolean;
@OneToMany(() => TagEntity, (tag) => tag.model)
tags: TagEntity[];
}