2024-03-20 16:02:51 -05:00
|
|
|
import { AssetEntity } from 'src/entities/asset.entity';
|
2024-01-27 18:52:14 +00:00
|
|
|
import { Column, Entity, JoinColumn, OneToMany, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
|
|
|
|
|
|
|
|
@Entity('asset_stack')
|
2024-07-05 09:08:36 -04:00
|
|
|
export class StackEntity {
|
2024-01-27 18:52:14 +00:00
|
|
|
@PrimaryGeneratedColumn('uuid')
|
|
|
|
|
id!: string;
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => AssetEntity, (asset) => asset.stack)
|
|
|
|
|
assets!: AssetEntity[];
|
|
|
|
|
|
|
|
|
|
@OneToOne(() => AssetEntity)
|
|
|
|
|
@JoinColumn()
|
|
|
|
|
//TODO: Add constraint to ensure primary asset exists in the assets array
|
|
|
|
|
primaryAsset!: AssetEntity;
|
|
|
|
|
|
|
|
|
|
@Column({ nullable: false })
|
|
|
|
|
primaryAssetId!: string;
|
2024-06-09 21:19:28 +02:00
|
|
|
|
|
|
|
|
assetCount?: number;
|
2024-01-27 18:52:14 +00:00
|
|
|
}
|