import { Exclude } from 'class-transformer'; import { getConnection } from 'typeorm'; import { Donation } from '../../entities/Donation'; import { Donor } from '../../entities/Donor'; /** * This class is used to create a new Donation entity from a json body (post request). */ export abstract class CreateDonation { @Exclude() donor: number; @Exclude() paidAmount?: number; /** * Creates a new Donation entity from this. */ public abstract toEntity(): Promise; /** * Gets a donor based on the donor id provided via this.donor. */ public async getDonor(): Promise { const donor = await getConnection().getRepository(Donor).findOne({ id: this.donor }); return donor; } }