mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 22:14:53 +00:00
added project community relation
This commit is contained in:
@ -1,7 +1,8 @@
|
|||||||
import { Column, Entity, OneToMany, Unique } from 'typeorm';
|
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { CommunityDto } from '../dtos';
|
import { CommunityDto } from '../dtos';
|
||||||
import { SpaceEntity } from '../../space/entities';
|
import { SpaceEntity } from '../../space/entities';
|
||||||
|
import { ProjectEntity } from '../../project/entities';
|
||||||
|
|
||||||
@Entity({ name: 'community' })
|
@Entity({ name: 'community' })
|
||||||
@Unique(['name'])
|
@Unique(['name'])
|
||||||
@ -31,4 +32,9 @@ export class CommunityEntity extends AbstractEntity<CommunityDto> {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
externalId: string;
|
externalId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProjectEntity, (project) => project.communities, {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
project: ProjectEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Entity, Column, Unique } from 'typeorm';
|
import { Entity, Column, Unique, OneToMany } from 'typeorm';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { ProjectDto } from '../dtos';
|
import { ProjectDto } from '../dtos';
|
||||||
|
import { CommunityEntity } from '../../community/entities';
|
||||||
|
|
||||||
@Entity({ name: 'project' })
|
@Entity({ name: 'project' })
|
||||||
@Unique(['name'])
|
@Unique(['name'])
|
||||||
@ -20,6 +21,9 @@ export class ProjectEntity extends AbstractEntity<ProjectDto> {
|
|||||||
@Column({ length: 255, nullable: true })
|
@Column({ length: 255, nullable: true })
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
|
@OneToMany(() => CommunityEntity, (community) => community.project)
|
||||||
|
communities: CommunityEntity[];
|
||||||
|
|
||||||
constructor(partial: Partial<ProjectEntity>) {
|
constructor(partial: Partial<ProjectEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
|
|||||||
Reference in New Issue
Block a user