2023-02-07 03:47:06 +01:00
|
|
|
import {
|
|
|
|
Column,
|
|
|
|
CreateDateColumn,
|
|
|
|
Entity,
|
|
|
|
ManyToOne,
|
|
|
|
OneToMany,
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
UpdateDateColumn,
|
|
|
|
} from 'typeorm';
|
2022-06-18 17:56:36 +02:00
|
|
|
import { AssetAlbumEntity } from './asset-album.entity';
|
2023-01-09 21:16:08 +01:00
|
|
|
import { SharedLinkEntity } from './shared-link.entity';
|
2022-06-18 17:56:36 +02:00
|
|
|
import { UserAlbumEntity } from './user-album.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
|
|
|
|
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
ownerId!: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-02-09 18:55:24 +01:00
|
|
|
@ManyToOne(() => UserEntity, { eager: true })
|
2023-02-07 03:47:06 +01:00
|
|
|
owner!: UserEntity;
|
|
|
|
|
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' })
|
2022-06-25 19:53:06 +02:00
|
|
|
createdAt!: string;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
2023-02-06 17:24:58 +01:00
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
|
|
updatedAt!: string;
|
|
|
|
|
2022-10-23 23:54:54 +02:00
|
|
|
@Column({ comment: 'Asset ID to be used as thumbnail', type: 'varchar', nullable: true })
|
2022-06-25 19:53:06 +02:00
|
|
|
albumThumbnailAssetId!: string | null;
|
2022-06-18 17:56:36 +02:00
|
|
|
|
|
|
|
@OneToMany(() => UserAlbumEntity, (userAlbums) => userAlbums.albumInfo)
|
2022-06-25 19:53:06 +02:00
|
|
|
sharedUsers?: UserAlbumEntity[];
|
2022-06-18 17:56:36 +02:00
|
|
|
|
|
|
|
@OneToMany(() => AssetAlbumEntity, (assetAlbumEntity) => assetAlbumEntity.albumInfo)
|
2022-06-25 19:53:06 +02:00
|
|
|
assets?: AssetAlbumEntity[];
|
2023-01-09 21:16:08 +01:00
|
|
|
|
|
|
|
@OneToMany(() => SharedLinkEntity, (link) => link.album)
|
|
|
|
sharedLinks!: SharedLinkEntity[];
|
2022-06-18 17:56:36 +02:00
|
|
|
}
|