This commit is contained in:
Alex Tran 2023-08-10 13:26:42 -05:00
parent e9b0840f01
commit d92dbbe655
3 changed files with 33 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import {
} from 'typeorm';
import { AssetEntity } from './asset.entity';
import { SharedLinkEntity } from './shared-link.entity';
import { SmartAlbumPolicyEntity } from './smart-album-policy.entity';
import { UserEntity } from './user.entity';
@Entity('albums')
@ -52,4 +53,7 @@ export class AlbumEntity {
@OneToMany(() => SharedLinkEntity, (link) => link.album)
sharedLinks!: SharedLinkEntity[];
@OneToMany(() => SmartAlbumPolicyEntity, (policy) => policy.album)
policies!: SmartAlbumPolicyEntity[];
}

View file

@ -5,6 +5,7 @@ import { AssetEntity } from './asset.entity';
import { PartnerEntity } from './partner.entity';
import { PersonEntity } from './person.entity';
import { SharedLinkEntity } from './shared-link.entity';
import { SmartAlbumPolicyEntity } from './smart-album-policy.entity';
import { SmartInfoEntity } from './smart-info.entity';
import { SystemConfigEntity } from './system-config.entity';
import { TagEntity } from './tag.entity';
@ -19,6 +20,7 @@ export * from './exif.entity';
export * from './partner.entity';
export * from './person.entity';
export * from './shared-link.entity';
export * from './smart-album-policy.entity';
export * from './smart-info.entity';
export * from './system-config.entity';
export * from './tag.entity';
@ -33,6 +35,7 @@ export const databaseEntities = [
PartnerEntity,
PersonEntity,
SharedLinkEntity,
SmartAlbumPolicyEntity,
SmartInfoEntity,
SystemConfigEntity,
TagEntity,

View file

@ -0,0 +1,26 @@
import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { AlbumEntity } from './album.entity';
@Entity('smart-album-policies')
export class SmartAlbumPolicyEntity {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column()
type!: PolicyType;
@Column()
value!: string;
@Column()
albumId!: string;
@Index('IDX_smartAlbumPolicy_albumId')
@ManyToOne(() => AlbumEntity, (album) => album.policies, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
album!: AlbumEntity;
}
export enum PolicyType {
PERSON = 'PERSON',
LOCATION = 'LOCATION',
}