Loading backend/src/place/entities/available-date.entity.ts +4 −4 Original line number Diff line number Diff line import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'; import { Place } from './place.entity'; @Entity() export class AvailableDate { @PrimaryGeneratedColumn() idAvailableDate: number; @PrimaryColumn() idPlace: number; @JoinColumn({ name: 'idPlace' }) @ManyToOne(() => Place, (place) => place.availableDates, { nullable: false }) idPlace: Place; place: Place; @Column() startDate: Date; Loading backend/src/place/entities/place.entity.ts +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ export class Place { @OneToMany(() => PointOfInterest, (point) => point.idPoint) points: PointOfInterest[]; @OneToMany(() => AvailableDate, (available) => available.idPlace) @OneToMany(() => AvailableDate, (available) => available.place) availableDates: AvailableDate[]; @ManyToMany(() => Category) Loading backend/src/place/place.service.ts +13 −4 Original line number Diff line number Diff line Loading @@ -76,7 +76,11 @@ export class PlaceService { await this.placeTraductionRepository.insert(createTradEs); await this.placeTraductionRepository.insert(createTradEn); if (createPlaceDto.available === Available.CUSTOM) { await this.availableDateRepository.insert({ ...createDate, idPlace: insertedPlace }); await this.availableDateRepository.insert({ ...createDate, place: insertedPlace, idPlace: insertedPlace.idPlace, }); } } Loading Loading @@ -202,9 +206,14 @@ export class PlaceService { // Update available date if necessary if (updatePlaceReqDto.available === Available.CUSTOM) { await this.availableDateRepository.update( { idPlace: place }, { startDate: updatePlaceReqDto.startDate, endDate: updatePlaceReqDto.endDate }, await this.availableDateRepository.upsert( { idPlace: place.idPlace, place: place, startDate: updatePlaceReqDto.startDate, endDate: updatePlaceReqDto.endDate, }, ['idPlace'], ); } } Loading Loading
backend/src/place/entities/available-date.entity.ts +4 −4 Original line number Diff line number Diff line import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'; import { Place } from './place.entity'; @Entity() export class AvailableDate { @PrimaryGeneratedColumn() idAvailableDate: number; @PrimaryColumn() idPlace: number; @JoinColumn({ name: 'idPlace' }) @ManyToOne(() => Place, (place) => place.availableDates, { nullable: false }) idPlace: Place; place: Place; @Column() startDate: Date; Loading
backend/src/place/entities/place.entity.ts +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ export class Place { @OneToMany(() => PointOfInterest, (point) => point.idPoint) points: PointOfInterest[]; @OneToMany(() => AvailableDate, (available) => available.idPlace) @OneToMany(() => AvailableDate, (available) => available.place) availableDates: AvailableDate[]; @ManyToMany(() => Category) Loading
backend/src/place/place.service.ts +13 −4 Original line number Diff line number Diff line Loading @@ -76,7 +76,11 @@ export class PlaceService { await this.placeTraductionRepository.insert(createTradEs); await this.placeTraductionRepository.insert(createTradEn); if (createPlaceDto.available === Available.CUSTOM) { await this.availableDateRepository.insert({ ...createDate, idPlace: insertedPlace }); await this.availableDateRepository.insert({ ...createDate, place: insertedPlace, idPlace: insertedPlace.idPlace, }); } } Loading Loading @@ -202,9 +206,14 @@ export class PlaceService { // Update available date if necessary if (updatePlaceReqDto.available === Available.CUSTOM) { await this.availableDateRepository.update( { idPlace: place }, { startDate: updatePlaceReqDto.startDate, endDate: updatePlaceReqDto.endDate }, await this.availableDateRepository.upsert( { idPlace: place.idPlace, place: place, startDate: updatePlaceReqDto.startDate, endDate: updatePlaceReqDto.endDate, }, ['idPlace'], ); } } Loading