오후 8시 15분.
- 뒹굴거리다가 개발 시작. 저번에 해결못했던
- 그리고 실행하니까 (node:19273) UnhandledPromiseRejectionWarning: QueryFailedError: ER_CANNOT_ADD_FOREIGN: Cannot add foreign key constraint 이런 에러가 뜬다...
위 에러를 해결해야 한다.
아무래도 typeorm 엔티티 설정하는 과정에서
No overload matches this call.
Overload 1 of 2, '(ids: any[], options?: FindManyOptions<User> | undefined): Promise<User[]>', gave the following error.
Argument of type 'readonly string[]' is not assignable to parameter of type 'any[]'.
The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'.
Overload 2 of 2, '(ids: any[], conditions?: FindConditions<User> | undefined): Promise<User[]>', gave the following error.
Argument of type 'readonly string[]' is not assignable to parameter of type 'any[]'.
The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'.
위 오류를 먼저 해결해야 하는것 같다.
위 오류는
export const createUserLoader = () =>
new DataLoader<string, User>(async ids => {
const repo = getRepository(User);
const users = await repo.findByIds(ids);
const normalized = normalize(users, user => user.id);
return ids.map(id => normalized[id]);
});
위 코드에서 오류가 난다.
이 오류는 dataloader 버전 1.4.0로 내리니까 해결이 되었고,
맨 위 오류는 typeorm에서
@Entity('users', {
synchronize: true
})
위 설정을 true로 바꾸니까 되었다.
오후 9시 11분
- 그 다음 오류는 QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[object Object], `about` text NOT NULL, UNIQUE INDEX `REL_4d1ba207780eda27a88856' at line 1
typeORM 설정에서 쿼리를 보니 기본 default 값 타입으로 any 가 들어가는데 object Object] 로 나온다.
ㄴ 해당 컬럼 필요없어서 삭제해서 진행
-mysql에서 일반 인덱스랑 유니크 인덱스랑 둘다 설정할 필요는 없다고 해서 유니크 인덱스만 남기고 삭제
드디어 DB 연결 완료!!
- 쿠키 파서 등록 해야한다.
오후 10시 46분
- 쿠키를 등록했는데 자꾸 빈 객체만 나온다..
[Object: null prototype] {} 이렇게 나오고 쿠키 파서 등록 안했을때는 req.cookies가 undefined라고 나오고...
'개발일지' 카테고리의 다른 글
[developergarten 개발기] 9. 프론트엔드 로그인 버튼 구현 (0) | 2020.06.06 |
---|---|
[developergarten 개발기] 8. github 소셜 로그인 구현 실제 (5) (0) | 2020.05.31 |
[developergarten 개발기] 6. github 소셜 로그인 구현 실제 (3) (0) | 2020.05.24 |
[developergarten 개발기] 5. github 소셜 로그인 구현 실제 (2) (0) | 2020.05.24 |
[developergarten 개발기] 4. github 소셜 로그인 구현 실제 (1) (0) | 2020.05.23 |