36
									
								
								src/models/entities/Donation.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/models/entities/Donation.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| 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; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user