updated tag with relation

This commit is contained in:
hannathkadher
2025-02-10 12:58:13 +04:00
parent f381820049
commit 8d4e10ff1c
7 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1 @@
export * from './tag.dto';

View File

@ -1 +1 @@
export * from './tag.entity';
export * from './tag.entity';

View File

@ -1,8 +1,10 @@
import { Entity, Column, ManyToOne, Unique } from 'typeorm';
import { Entity, Column, ManyToOne, Unique, OneToMany } from 'typeorm';
import { ProductEntity } from '../../product/entities';
import { ProjectEntity } from '../../project/entities';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { NewTagDto } from '../dtos/tag.dto';
import { SpaceModelProductAllocationEntity } from '../../space-model/entities/space-model-product-allocation.entity';
import { SubspaceProductAllocation } from '../../space';
@Entity({ name: 'tag' })
@Unique(['name', 'project'])
@ -29,6 +31,18 @@ export class NewTagEntity extends AbstractEntity<NewTagDto> {
})
public project: ProjectEntity;
@OneToMany(
() => SpaceModelProductAllocationEntity,
(allocation) => allocation.allowedTags,
)
public spaceModelAllocations: SpaceModelProductAllocationEntity[];
@OneToMany(
() => SubspaceProductAllocation,
(allocation) => allocation.allowedTags,
)
public subspaceAllocations: SubspaceProductAllocation[];
constructor(partial: Partial<NewTagEntity>) {
super();
Object.assign(this, partial);

View File

@ -0,0 +1 @@
export * from './entities';

View File

@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { NewTagEntity } from '../entities';
import { DataSource, Repository } from 'typeorm';
@Injectable()
export class NewTagRepository extends Repository<NewTagRepository> {
constructor(private dataSource: DataSource) {
super(NewTagEntity, dataSource.createEntityManager());
}
}

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { NewTagEntity } from './entities';
@Module({
providers: [],
exports: [],
controllers: [],
imports: [TypeOrmModule.forFeature([NewTagEntity])],
})
export class NewTagRepositoryModule {}