36 lines
853 B
TypeScript
36 lines
853 B
TypeScript
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, TableInheritance } from "typeorm";
|
|
import {
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsPositive,
|
|
} from "class-validator";
|
|
import { Participant } from "./Participant";
|
|
|
|
/**
|
|
* Defines the donation interface.
|
|
*/
|
|
@Entity()
|
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
|
export abstract class Donation {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsOptional()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* The donations's donor.
|
|
*/
|
|
@IsNotEmpty()
|
|
@ManyToOne(() => Participant, donor => donor.donations, { nullable: true })
|
|
donor: Participant;
|
|
|
|
/**
|
|
* The donation's amount in cents (or whatever your currency's smallest unit is.).
|
|
* The exact implementation may differ for each type of donation.
|
|
*/
|
|
abstract amount: number;
|
|
} |