Skip to content

Commit

Permalink
Fix: Delete Like Error
Browse files Browse the repository at this point in the history
- place에 likedUser 추가 과정에서 발생한 에러 해결
- like remove시 placeForMap.place가 undefined인 에러 발생
- polulate에 likedUser.likedPlace.place 추가

- 성능 향상을 위해 그 외에 사용하지않는 populate 제거
  • Loading branch information
sally0226 committed Sep 13, 2024
1 parent 0cb807d commit 768f888
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/entities/place-for-map.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PlaceForMap {
})
likedUserIds: number[];

@ManyToMany(() => User, (p) => p.likedPlace, { nullable: true })
@ManyToMany(() => User, (p: User) => p.likedPlace, { nullable: true })
likedUser = new Collection<User>(this);

@ManyToMany(() => Tag, 'placeForMap', { owner: true })
Expand Down
2 changes: 1 addition & 1 deletion src/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class User {
@Property({ onUpdate: () => new Date() })
updatedAt: Date = new Date();

@ManyToMany(() => PlaceForMap, (p) => p.likedUser, {
@ManyToMany(() => PlaceForMap, (p: PlaceForMap) => p.likedUser, {
owner: true,
nullable: true,
})
Expand Down
2 changes: 1 addition & 1 deletion src/place/place.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class PlaceController {
async getPlaceInMap(
@Param('mapId') mapId: string,
@Param('placeId') placeId: number,
) {
): Promise<PlaceResponseDto> {
return await this.placeService.getPlace(mapId, placeId);
}

Expand Down
8 changes: 1 addition & 7 deletions src/place/place.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,7 @@ export class PlaceService {
map: rel(GroupMap, mapId),
},
{
populate: [
'place',
'place.kakaoPlace',
'createdBy',
'tags',
'likedUser.id',
],
populate: ['place', 'likedUser.id', 'likedUser.likedPlace.place'],
},
);

Expand Down

0 comments on commit 768f888

Please sign in to comment.