2023-02-07 03:47:06 +01:00
|
|
|
import {
|
|
|
|
Column,
|
|
|
|
CreateDateColumn,
|
|
|
|
Entity,
|
2023-02-18 21:58:55 +01:00
|
|
|
JoinTable,
|
|
|
|
ManyToMany,
|
2023-02-07 03:47:06 +01:00
|
|
|
ManyToOne,
|
|
|
|
OneToMany,
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
UpdateDateColumn,
|
|
|
|
} from 'typeorm';
|
2023-02-18 21:58:55 +01:00
|
|
|
import { AssetEntity } from './asset.entity';
|
2023-06-16 21:54:17 +02:00
|
|
|
import { SharedLinkEntity } from './shared-link.entity';
|
2023-02-07 03:47:06 +01:00
|
|
|
import { UserEntity } from './user.entity';
|
2022-06-18 17:56:36 +02:00
|
|
|
|
|
|
|
@Entity('albums')
|
|
|
|
export class AlbumEntity {
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
2022-06-25 19:53:06 +02:00
|
|
|
id!: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
2023-02-18 21:58:55 +01:00
|
|
|
owner!: UserEntity;
|
|
|
|
|
2022-06-18 17:56:36 +02:00
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
ownerId!: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
|
|
|
@Column({ default: 'Untitled Album' })
|
2022-06-25 19:53:06 +02:00
|
|
|
albumName!: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
2023-05-30 15:15:56 +02:00
|
|
|
createdAt!: Date;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-02-06 17:24:58 +01:00
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
2023-05-30 15:15:56 +02:00
|
|
|
updatedAt!: Date;
|
2023-02-06 17:24:58 +01:00
|
|
|
|
2023-03-04 15:16:48 +01:00
|
|
|
@ManyToOne(() => AssetEntity, { nullable: true, onDelete: 'SET NULL', onUpdate: 'CASCADE' })
|
|
|
|
albumThumbnailAsset!: AssetEntity | null;
|
|
|
|
|
|
|
|
@Column({ comment: 'Asset ID to be used as thumbnail', nullable: true })
|
2022-06-25 19:53:06 +02:00
|
|
|
albumThumbnailAssetId!: string | null;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@ManyToMany(() => UserEntity)
|
2023-02-18 21:58:55 +01:00
|
|
|
@JoinTable()
|
|
|
|
sharedUsers!: UserEntity[];
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-04-10 04:48:01 +02:00
|
|
|
@ManyToMany(() => AssetEntity, (asset) => asset.albums)
|
2023-02-18 21:58:55 +01:00
|
|
|
@JoinTable()
|
|
|
|
assets!: AssetEntity[];
|
2023-01-09 21:16:08 +01:00
|
|
|
|
|
|
|
@OneToMany(() => SharedLinkEntity, (link) => link.album)
|
|
|
|
sharedLinks!: SharedLinkEntity[];
|
2022-06-18 17:56:36 +02:00
|
|
|
}
|