immich/server/src/schema/tables/shared-link.table.ts

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-03-28 10:40:09 -04:00
import { SharedLinkType } from 'src/enum';
2025-03-29 09:26:24 -04:00
import { AlbumTable } from 'src/schema/tables/album.table';
import { UserTable } from 'src/schema/tables/user.table';
2025-04-17 14:41:06 -04:00
import { Column, CreateDateColumn, ForeignKeyColumn, PrimaryGeneratedColumn, Table, Unique } from 'src/sql-tools';
2025-03-28 10:40:09 -04:00
@Table('shared_links')
@Unique({ name: 'UQ_sharedlink_key', columns: ['key'] })
export class SharedLinkTable {
@PrimaryGeneratedColumn()
id!: string;
@Column({ type: 'character varying', nullable: true })
description!: string | null;
@ForeignKeyColumn(() => UserTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
userId!: string;
2025-04-17 14:41:06 -04:00
@Column({ type: 'bytea', indexName: 'IDX_sharedlink_key' })
key!: Buffer; // use to access the individual asset
2025-03-28 10:40:09 -04:00
@Column()
type!: SharedLinkType;
@CreateDateColumn()
createdAt!: Date;
@Column({ type: 'timestamp with time zone', nullable: true })
expiresAt!: Date | null;
@Column({ type: 'boolean', default: false })
allowUpload!: boolean;
2025-04-17 14:41:06 -04:00
@ForeignKeyColumn(() => AlbumTable, {
nullable: true,
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
indexName: 'IDX_sharedlink_albumId',
})
albumId!: string;
2025-03-28 10:40:09 -04:00
@Column({ type: 'boolean', default: true })
allowDownload!: boolean;
@Column({ type: 'boolean', default: true })
showExif!: boolean;
@Column({ type: 'character varying', nullable: true })
password!: string | null;
2025-03-28 10:40:09 -04:00
}