mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 18:44:54 +00:00
33 lines
905 B
TypeScript
33 lines
905 B
TypeScript
import { Column, Entity, ManyToOne, JoinColumn } from 'typeorm';
|
|
import { SpaceEntity } from './space.entity';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { ProductEntity } from '../../product/entities';
|
|
|
|
@Entity({ name: 'space-product' })
|
|
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
|
@ManyToOne(() => SpaceEntity, (space) => space.spaceProducts, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'space_id' })
|
|
space: SpaceEntity;
|
|
|
|
@ManyToOne(() => ProductEntity, (product) => product.spaceProducts, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'product_id' })
|
|
product: ProductEntity;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
type: 'int',
|
|
})
|
|
productCount: number;
|
|
|
|
constructor(partial: Partial<SpaceProductEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|