RenaiApp/src/main/entities/library/collection.ts

33 lines
1.0 KiB
TypeScript

import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { CollectionName } from './collection-name';
import { CollectionPart } from './collection-part';
/**
* A collection is a set of works.
* For example, this can be a series or a set of alternate angles.
* What constitutes as a collection is ultimately up to the user.
*
* As a general rule of thumb:
* If authors of works see them as belonging together, they are a collection
*/
@Entity()
export class Collection implements IdentifiableEntityInterface, MultiNamedEntityInterface {
@PrimaryGeneratedColumn()
public id!: number;
@Column({
nullable: false,
default: '',
})
public nameCanonical!: string;
@OneToMany(() => CollectionName, (collectionName: CollectionName) => collectionName.entity)
public names!: Promise<CollectionName[]>;
/**
* the connecting entity between this collection and the work
*/
@OneToMany(() => CollectionPart, (collectionPart: CollectionPart) => collectionPart.collection)
public parts!: Promise<CollectionPart[]>;
}