mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-10 04:07:35 +02:00
Adding more indices to fields and improving SQL queries #437
This commit is contained in:
parent
65c4ab161c
commit
eea77a5bea
@ -1,41 +0,0 @@
|
||||
import { FaceRegionBox } from '../../../../../common/entities/PhotoDTO';
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { PersonEntry } from './PersonEntry';
|
||||
import { MediaEntity } from './MediaEntity';
|
||||
|
||||
export class FaceRegionBoxEntry implements FaceRegionBox {
|
||||
@Column('int')
|
||||
height: number;
|
||||
@Column('int')
|
||||
width: number;
|
||||
@Column('int')
|
||||
left: number;
|
||||
@Column('int')
|
||||
top: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a switching table between media and persons
|
||||
*/
|
||||
@Entity()
|
||||
export class FaceRegionEntry {
|
||||
@PrimaryGeneratedColumn({ unsigned: true })
|
||||
id: number;
|
||||
|
||||
@Column((type) => FaceRegionBoxEntry)
|
||||
box: FaceRegionBoxEntry;
|
||||
|
||||
@ManyToOne((type) => MediaEntity, (media) => media.metadata.faces, {
|
||||
onDelete: 'CASCADE',
|
||||
nullable: false,
|
||||
})
|
||||
media: MediaEntity;
|
||||
|
||||
@ManyToOne((type) => PersonEntry, (person) => person.faces, {
|
||||
onDelete: 'CASCADE',
|
||||
nullable: false,
|
||||
})
|
||||
person: PersonEntry;
|
||||
|
||||
name: string;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
import {Entity, Index, ManyToOne, PrimaryGeneratedColumn} from 'typeorm';
|
||||
import {PersonEntry} from './PersonEntry';
|
||||
import {MediaEntity} from './MediaEntity';
|
||||
|
||||
|
||||
/**
|
||||
* This is a junction table between media and persons
|
||||
*/
|
||||
@Entity()
|
||||
export class PersonJunctionTable {
|
||||
@Index()
|
||||
@PrimaryGeneratedColumn({unsigned: true})
|
||||
id: number;
|
||||
|
||||
@Index()
|
||||
@ManyToOne((type) => MediaEntity, (media) => media.metadata.faces, {
|
||||
onDelete: 'CASCADE',
|
||||
nullable: false,
|
||||
})
|
||||
media: MediaEntity;
|
||||
|
||||
@Index()
|
||||
@ManyToOne((type) => PersonEntry, (person) => person.faces, {
|
||||
onDelete: 'CASCADE',
|
||||
nullable: false,
|
||||
})
|
||||
person: PersonEntry;
|
||||
}
|
Loading…
Reference in New Issue
Block a user