src/model*: unique fields

added unique contraines to some fields. For Example, name of CargoBike,
workshopType and the combination of name and firstName of Person.
pull/20/head
leonnicolas 4 years ago
parent f80f619ed9
commit c193a63785
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -183,7 +183,9 @@ export class CargoBike implements Lockable {
}) })
group: Group; group: Group;
@Column() @Column({
unique: true
})
name: string; name: string;
@OneToMany(type => Equipment, equipment => equipment.cargoBikeId, { @OneToMany(type => Equipment, equipment => equipment.cargoBikeId, {

@ -26,7 +26,9 @@ export class EngagementType implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column() @Column({
unique: true
})
name: string; name: string;
@Column({ @Column({

@ -25,7 +25,9 @@ export class EquipmentType implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column() @Column({
unique: true
})
name: string; name: string;
@Column({ @Column({

@ -28,7 +28,9 @@ export class Organisation implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column() @Column({
unique: true
})
name: string; name: string;
@OneToMany(type => LendingStation, lendingStation => lendingStation.organisationId) @OneToMany(type => LendingStation, lendingStation => lendingStation.organisationId)

@ -18,10 +18,11 @@ This file is part of fLotte-API-Server.
*/ */
import { Lockable } from './CargoBike'; import { Lockable } from './CargoBike';
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';
import { ContactInformation } from './ContactInformation'; import { ContactInformation } from './ContactInformation';
@Entity() @Entity()
@Unique(['firstName', 'name'])
export class Person implements Lockable { export class Person implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;

@ -26,7 +26,9 @@ export class WorkshopType implements Lockable {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column() @Column({
unique: true
})
name: string; name: string;
@OneToMany(type => Workshop, workshop => workshop.workshopTypeId) @OneToMany(type => Workshop, workshop => workshop.workshopTypeId)

Loading…
Cancel
Save