Updated relationships to be nullable

ref #11 #13
This commit is contained in:
Nicolai Ort 2020-12-02 19:45:02 +01:00
parent aa565c6b34
commit 4c80ab1516
17 changed files with 32 additions and 32 deletions

View File

@ -76,12 +76,12 @@ export class Address {
/** /**
* Used to link the address to participants. * Used to link the address to participants.
*/ */
@OneToMany(() => Participant, participant => participant.address) @OneToMany(() => Participant, participant => participant.address, { nullable: true })
participants: Participant[]; participants: Participant[];
/** /**
* Used to link the address to runner groups. * Used to link the address to runner groups.
*/ */
@OneToMany(() => RunnerOrganisation, group => group.address) @OneToMany(() => RunnerOrganisation, group => group.address, { nullable: true })
groups: RunnerOrganisation[]; groups: RunnerOrganisation[];
} }

View File

@ -13,7 +13,7 @@ export class DistanceDonation extends Donation {
* The runner associated. * The runner associated.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => Runner, runner => runner.distanceDonations) @ManyToOne(() => Runner, runner => runner.distanceDonations, { nullable: true })
runner: Runner; runner: Runner;
/** /**

View File

@ -24,7 +24,7 @@ export abstract class Donation {
* The donations's donor. * The donations's donor.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => Participant, donor => donor.donations) @ManyToOne(() => Participant, donor => donor.donations, { nullable: true })
donor: Participant; donor: Participant;
/** /**

View File

@ -55,7 +55,7 @@ export class GroupContact {
* Optional * Optional
*/ */
@IsOptional() @IsOptional()
@ManyToOne(() => Address, address => address.participants) @ManyToOne(() => Address, address => address.participants, { nullable: true })
address?: Address; address?: Address;
/** /**
@ -79,12 +79,12 @@ export class GroupContact {
/** /**
* Used to link the contact as the donor of a donation. * Used to link the contact as the donor of a donation.
*/ */
@OneToMany(() => Donation, donation => donation.donor) @OneToMany(() => Donation, donation => donation.donor, { nullable: true })
donations: Donation[]; donations: Donation[];
/** /**
* Used to link runners to donations. * Used to link runners to donations.
*/ */
@OneToMany(() => RunnerGroup, group => group.contact) @OneToMany(() => RunnerGroup, group => group.contact, { nullable: true })
groups: RunnerGroup[]; groups: RunnerGroup[];
} }

View File

@ -53,7 +53,7 @@ export abstract class Participant {
* The participant's address. * The participant's address.
* Optional * Optional
*/ */
@ManyToOne(() => Address, address => address.participants) @ManyToOne(() => Address, address => address.participants, { nullable: true })
address?: Address; address?: Address;
/** /**
@ -77,6 +77,6 @@ export abstract class Participant {
/** /**
* Used to link the participant as the donor of a donation. * Used to link the participant as the donor of a donation.
*/ */
@OneToMany(() => Donation, donation => donation.donor) @OneToMany(() => Donation, donation => donation.donor, { nullable: true })
donations: Donation[]; donations: Donation[];
} }

View File

@ -23,13 +23,13 @@ export abstract class Permission {
/** /**
* users * users
*/ */
@OneToMany(() => User, user => user.permissions) @OneToMany(() => User, user => user.permissions, { nullable: true })
users: User[] users: User[]
/** /**
* groups * groups
*/ */
@OneToMany(() => UserGroup, group => group.permissions) @OneToMany(() => UserGroup, group => group.permissions, { nullable: true })
groups: UserGroup[] groups: UserGroup[]
/** /**

View File

@ -15,25 +15,25 @@ export class Runner extends Participant {
* The runner's associated group. * The runner's associated group.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => RunnerGroup, group => group.runners) @ManyToOne(() => RunnerGroup, group => group.runners, { nullable: true })
group: RunnerGroup; group: RunnerGroup;
/** /**
* Used to link runners to donations. * Used to link runners to donations.
*/ */
@OneToMany(() => DistanceDonation, distanceDonation => distanceDonation.runner) @OneToMany(() => DistanceDonation, distanceDonation => distanceDonation.runner, { nullable: true })
distanceDonations: DistanceDonation[]; distanceDonations: DistanceDonation[];
/** /**
* Used to link runners to cards. * Used to link runners to cards.
*/ */
@OneToMany(() => RunnerCard, card => card.runner) @OneToMany(() => RunnerCard, card => card.runner, { nullable: true })
cards: RunnerCard[]; cards: RunnerCard[];
/** /**
* Used to link runners to a scans * Used to link runners to a scans
*/ */
@OneToMany(() => Scan, scan => scan.runner) @OneToMany(() => Scan, scan => scan.runner, { nullable: true })
scans: Scan[]; scans: Scan[];
@IsInt() @IsInt()

View File

@ -26,7 +26,7 @@ export class RunnerCard {
* The runner that is currently associated with this card. * The runner that is currently associated with this card.
*/ */
@IsOptional() @IsOptional()
@ManyToOne(() => Runner, runner => runner.cards) @ManyToOne(() => Runner, runner => runner.cards, { nullable: true })
runner: Runner; runner: Runner;
/** /**
@ -51,6 +51,6 @@ export class RunnerCard {
/** /**
* Used to link cards to a track scans. * Used to link cards to a track scans.
*/ */
@OneToMany(() => TrackScan, scan => scan.track) @OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
scans: TrackScan[]; scans: TrackScan[];
} }

View File

@ -35,12 +35,12 @@ export abstract class RunnerGroup {
* Optional * Optional
*/ */
@IsOptional() @IsOptional()
@ManyToOne(() => GroupContact, contact => contact.groups) @ManyToOne(() => GroupContact, contact => contact.groups, { nullable: true })
contact?: GroupContact; contact?: GroupContact;
/** /**
* Used to link runners to a runner group. * Used to link runners to a runner group.
*/ */
@OneToMany(() => Runner, runner => runner.group) @OneToMany(() => Runner, runner => runner.group, { nullable: true })
runners: Runner[]; runners: Runner[];
} }

View File

@ -15,12 +15,12 @@ export class RunnerOrganisation extends RunnerGroup {
* Optional * Optional
*/ */
@IsOptional() @IsOptional()
@ManyToOne(() => Address, address => address.groups) @ManyToOne(() => Address, address => address.groups, { nullable: true })
address?: Address; address?: Address;
/** /**
* Used to link teams to runner groups. * Used to link teams to runner groups.
*/ */
@OneToMany(() => RunnerTeam, team => team.parentGroup) @OneToMany(() => RunnerTeam, team => team.parentGroup, { nullable: true })
teams: RunnerTeam[]; teams: RunnerTeam[];
} }

View File

@ -14,6 +14,6 @@ export class RunnerTeam extends RunnerGroup {
* Optional * Optional
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => RunnerOrganisation, org => org.teams) @ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: true })
parentGroup?: RunnerOrganisation; parentGroup?: RunnerOrganisation;
} }

View File

@ -25,7 +25,7 @@ export abstract class Scan {
* The associated runner. * The associated runner.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => Runner, runner => runner.scans) @ManyToOne(() => Runner, runner => runner.scans, { nullable: true })
runner: Runner; runner: Runner;
/** /**

View File

@ -34,7 +34,7 @@ export class ScanStation {
* The track this station is associated with. * The track this station is associated with.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => Track, track => track.stations) @ManyToOne(() => Track, track => track.stations, { nullable: true })
track: Track; track: Track;
/** /**
@ -56,6 +56,6 @@ export class ScanStation {
/** /**
* Used to link track scans to a scan station. * Used to link track scans to a scan station.
*/ */
@OneToMany(() => TrackScan, scan => scan.track) @OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
scans: TrackScan[]; scans: TrackScan[];
} }

View File

@ -41,12 +41,12 @@ export class Track {
/** /**
* Used to link scan stations to track. * Used to link scan stations to track.
*/ */
@OneToMany(() => ScanStation, station => station.track) @OneToMany(() => ScanStation, station => station.track, { nullable: true })
stations: ScanStation[]; stations: ScanStation[];
/** /**
* Used to link track scans to a track. * Used to link track scans to a track.
*/ */
@OneToMany(() => TrackScan, scan => scan.track) @OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
scans: TrackScan[]; scans: TrackScan[];
} }

View File

@ -22,21 +22,21 @@ export class TrackScan extends Scan {
* The associated track. * The associated track.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => Track, track => track.scans) @ManyToOne(() => Track, track => track.scans, { nullable: true })
track: Track; track: Track;
/** /**
* The associated card. * The associated card.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => RunnerCard, card => card.scans) @ManyToOne(() => RunnerCard, card => card.scans, { nullable: true })
card: RunnerCard; card: RunnerCard;
/** /**
* The scanning station. * The scanning station.
*/ */
@IsNotEmpty() @IsNotEmpty()
@ManyToOne(() => ScanStation, station => station.scans) @ManyToOne(() => ScanStation, station => station.scans, { nullable: true })
station: ScanStation; station: ScanStation;
/** /**

View File

@ -67,7 +67,7 @@ export class User {
/** /**
* permissions * permissions
*/ */
@ManyToOne(() => Permission, permission => permission.users) @ManyToOne(() => Permission, permission => permission.users, { nullable: true })
permissions: Permission[]; permissions: Permission[];
/** /**

View File

@ -23,7 +23,7 @@ export abstract class UserGroup {
/** /**
* permissions * permissions
*/ */
@ManyToOne(() => Permission, permission => permission.groups) @ManyToOne(() => Permission, permission => permission.groups, { nullable: true })
permissions: Permission[]; permissions: Permission[];
/** /**