backend/src/models/Donation.ts
2020-12-02 16:00:09 +01:00

34 lines
732 B
TypeScript

import { PrimaryGeneratedColumn, Column, ManyToOne } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsPositive,
} from "class-validator";
import { Participant } from "./Participant";
/**
* Defines the donation interface.
*/
export abstract class Donation {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The donations's donor.
*/
@IsNotEmpty()
@ManyToOne(() => Participant, donor => donor.donations)
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;
}