
오늘 한 일

위처럼 board_id가 자꾸 null로 되어있던 것... 이 문제는 팀원의 코드를 참고하여 고칠 수 있었다.
😂 원래 코드:
async createCatalog(title: string, sequence: number, boardId: number) {
await this.catalogRepository.save({
title,
sequence,
boardId,
});
return { message: `${boardId}의 ${title} catalog가 생성되었습니다.` };
}
😂 수정한 코드:
async createCatalog(title: string, sequence: number, boardId: number) {
const board = await this.boardRepository.findOneBy({ boardId });
await this.catalogRepository.save({
board,
title,
sequence,
});
console.log(boardId, sequence);
return { message: `${boardId}의 ${title} catalog가 생성되었습니다.` };
}
entity에 board:Board;라고 작성했는데 자꾸 typeof board를 쳐봐도 undefined가 나왔었는데 그냥 board 자체를 갖다 붙였어야했구나 깨달았다...