Inclui Models de Itinerary, Destination e NeighborhoodServed
This commit is contained in:
37
src/models/Destination.ts
Normal file
37
src/models/Destination.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import {
|
||||||
|
Entity,
|
||||||
|
Column,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
CreateDateColumn,
|
||||||
|
UpdateDateColumn,
|
||||||
|
ManyToOne,
|
||||||
|
JoinColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
import Itinerary from './Itinerary';
|
||||||
|
|
||||||
|
@Entity('destinations')
|
||||||
|
class Destination {
|
||||||
|
@PrimaryGeneratedColumn('increment')
|
||||||
|
id_destination: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => Itinerary, itinerary => itinerary.destinations)
|
||||||
|
@JoinColumn({ name: 'itinerary_id' })
|
||||||
|
itinerary: Itinerary;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
latitude: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
longitude: number;
|
||||||
|
|
||||||
|
// @CreateDateColumn()
|
||||||
|
// created_at: Date;
|
||||||
|
|
||||||
|
// @UpdateDateColumn()
|
||||||
|
// updated_at: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Destination;
|
||||||
@@ -5,7 +5,10 @@ import {
|
|||||||
CreateDateColumn,
|
CreateDateColumn,
|
||||||
UpdateDateColumn,
|
UpdateDateColumn,
|
||||||
OneToMany,
|
OneToMany,
|
||||||
|
JoinColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
import Destination from './Destination';
|
||||||
|
import NeighborhoodServed from './NeighborhoodServed';
|
||||||
import Vehicle from './Vehicle';
|
import Vehicle from './Vehicle';
|
||||||
|
|
||||||
@Entity('itineraries')
|
@Entity('itineraries')
|
||||||
@@ -37,6 +40,12 @@ class Itinerary {
|
|||||||
@Column()
|
@Column()
|
||||||
itinerary_nickname: string;
|
itinerary_nickname: string;
|
||||||
|
|
||||||
|
@OneToMany(() => NeighborhoodServed, neighborhoodServed => neighborhoodServed.itinerary, { eager: true, cascade: true, nullable: true })
|
||||||
|
neighborhoodsServed?: NeighborhoodServed[];
|
||||||
|
|
||||||
|
@OneToMany(() => Destination, destination => destination.itinerary, { eager: true, cascade: true, nullable: true })
|
||||||
|
destinations?: Destination[];
|
||||||
|
|
||||||
// @CreateDateColumn()
|
// @CreateDateColumn()
|
||||||
// created_at: Date;
|
// created_at: Date;
|
||||||
|
|
||||||
|
|||||||
37
src/models/NeighborhoodServed.ts
Normal file
37
src/models/NeighborhoodServed.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import {
|
||||||
|
Entity,
|
||||||
|
Column,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
CreateDateColumn,
|
||||||
|
UpdateDateColumn,
|
||||||
|
ManyToOne,
|
||||||
|
JoinColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
import Itinerary from './Itinerary';
|
||||||
|
|
||||||
|
@Entity('neighborhoods_served')
|
||||||
|
class NeighborhoodServed {
|
||||||
|
@PrimaryGeneratedColumn('increment')
|
||||||
|
id_neighborhood: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => Itinerary, itinerary => itinerary.neighborhoodsServed)
|
||||||
|
@JoinColumn({ name: 'itinerary_id' })
|
||||||
|
itinerary: Itinerary;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
latitude: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
longitude: number;
|
||||||
|
|
||||||
|
// @CreateDateColumn()
|
||||||
|
// created_at: Date;
|
||||||
|
|
||||||
|
// @UpdateDateColumn()
|
||||||
|
// updated_at: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NeighborhoodServed;
|
||||||
Reference in New Issue
Block a user