-
항해 99 5기 TIL_69항해 99 2022. 3. 20. 23:13
▶ Today I Learned
<실전 프로젝트>
[Sequelize seed]
칼럼의 값을 어떻게 수정할 수 있는지 궁금해서 다음과 같이 시도해보았다.
await queryInterface.bulkDelete("badges", [ { name: "beauty", createdAt: new Date, updatedAt: new Date, desc: "뷰티 카테고리 뱃지입니다.", imageUrl: "0" } ]) await queryInterface.bulkInsert("badges", [ { name: "beauty", createdAt: new Date, updatedAt: new Date, desc: "뷰티 카테고리 뱃지입니다.", imageUrl: "" // 위의 bulkDelete 부분을 제외하고 이 부분만 실행시켜보아도 에러는 똑같았다. },
하지만 단순히 삭제 후 새롭게 추가하는 방식은 먹히지 않았다.
EXTRA MESSAGE: Duplicate entry 'beauty' for key 'badges.name'
beauty라는 이름이 중복된다는 에러가 발생했다.
그렇다는 건 위 코드들은 기존의 beauty라는 속성값에 덧입히는 것이 아니라 추가하는 느낌의 코드인 듯 하다.
그렇기에 기존의 beauty가 남아있다고 계속 말해주는 것 같았다.
수정의 방법이 잘못된 것이라면 어떤 것이 더 있을까하고 찾아보던 중 아래의 링크에서 드디어 찾았다.
https://crispypotato.tistory.com/156?category=908293
..고 생각했으나
queryInterface.changeColumn
는 특정 컬럼에 들어갈 데이터의 속성을 바꾸는 것 뿐이었다...
문자열이 들어갈건지 뭐 이런것..
+ 계속 sequelize seeder에 대해 구글과 스택오버플로우에서 검색해보아도 특정 컴럼의 특정 레코드의 데이터를 수정하는 명령어는 보이지 않았다. 공식 문서는 어째서 인지 검색기능이 잘 작동하지 않아 구글에서 검색해서 나오는 공식문서들을 계속 들어가보았다.
하지만 거기서도 원하는 결과가 나오지는 않았다.
어쩌면 seeder, 초기 씨앗 심어주기, 측 초깃값 주기와 같은 이름처럼 애초에 수정하는 부분은 존재하지 않는게 아닐까라는 생각이 들었다.
다른 팀원 분에게도 여쭤보기로 하고 우선은 workbench에서 필요한 부분의 데이터는 직접 바꾸고 넘어 갔다.
기한 내 프로젝트에는 다른 중요한 요소들이 더 많기 때문에 이것만을 계속 붙잡고 있을 수는 없었다.
시간이 지나 또 보게 된다면 그땐 지금 보지 못했던 것을 보게 되고 알게 될 수도 있으니 이 편이 더 효율적이리라 믿는다.
<알고리즘>
[정수삼각형]
소요 시간: 53분 + 30분
해결 여부: 미해결
https://www.acmicpc.net/problem/1932
다이나믹 프로그래밍
지난 번에 이해한 것에 이어 추가적으로 더 이해하기 시작했다.
const N = 5 const input =[[7],[3, 8],[8, 1, 0],[2, 7, 4, 4],[4, 5, 2, 6, 5]] const sum = Array.from(new Array(N), () => new Array()); // Array.from(arrayLike, mapFn) 기본적으로 이런 형태다. // 즉, new Array(N)으로 만들어진 길이가 N인 배열의 첫번째 요소부터 끝 요소까지 빈 배열을 넣어주는 식이다. // sum[0].push(Number(input[0][0])); // [ [ 7 ], [], [], [], [] ] if (N > 1) { // n이 1이면 input[0][0]이 최댓값이기에 조건에 포함시키지 않음 for (let r = 1; r < N; r++) { for (let c = 0; c < input[r].length; c++) { if (c === 0) { sum[r].push(Number(sum[r - 1][c]) + Number(input[r][c])); // r = 1일 때, sum[1].push(sum[0][0] + input[1][0]) // r = 2, sum[2].push(sum[1][0] + input[2][0]) } else if (c === r) { sum[r].push(Number(sum[r - 1][c - 1]) + Number(input[r][c])); // r = 1, c = 1, sum[1].push(sum[0][0] + input[1][1]) } else { sum[r].push( Math.max(Number(sum[r - 1][c - 1]), Number(sum[r - 1][c])) + Number(input[r][c]) // r = 2, c =1, Math.max(sum[1][0], sum[1][1]) + input[2][1] ); } } } } console.log(Math.max(...sum[N - 1])); // 인덱스를 맞춰주기 위해 -1
프로젝트로 코딩을 하다 지난번 덜 이해한 문제를 다시 이해해보았다.
다른 날 또 시도해보아야지 :)
▶ 느낀 점
모두들 프로젝트로 인해 약간 지친 것이 보였다.
다들 쉬어가는 분위기였고 그간 모두들 고생하였기에 이런 시간도 필요하다 생각한다.
그래도 오늘 공부한 것을 정리하고 나니 꾸준히 해오고 있는 나,
제법 멋있어요 라는 생각도 든다 :3
▶ 공부 시 참고 링크들
https://hyang2data.tistory.com/15
https://dabo-dev.tistory.com/13
https://velog.io/@kwonh/Git-Rebase%EB%9E%80
'항해 99' 카테고리의 다른 글
항해 99 5기 WIL_10 (0) 2022.03.20 항해 99 5기 TIL_70 (0) 2022.03.20 항해 99 5기 TIL_68 (0) 2022.03.18 항해 99 5기 TIL_67 (0) 2022.03.18 항해 99 5기 TIL_66 (0) 2022.03.17