inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Node.js 교과서 - 기본부터 프로젝트 실습까지

버퍼와 스트림

index.js에서 hasmany 릴레이션 설정이 잘못된것 같아여

455

terecal

작성한 질문수 162

0

안녕하세여 강사님~!

관계 설정을 하고 나서 npm start를 실행하니가 에러가 발생하는데여

어디서 잘못되었는지 파악을 잘못하겠어서 검토해주시면 감사할게여~!

에러 메세지와 index.js는 다음과 같습니다.

error message :

(base) C:fast_ajaxnpm_startlearn-sequelize>npm start

learn-sequelize@0.0.0 start C:fast_ajaxnpm_startlearn-sequelize

node ./bin/www

sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modulessequelizelibsequelize.js:242:13

C:fast_ajaxnpm_startlearn-sequelizenode_modulessequelizelibassociationsmixin.js:13

throw new Error(this.name + '.hasMany called with something that\'s not a subclass of Sequelize.Model');

^

Error: user.hasMany called with something that's not a subclass of Sequelize.Model

at Function.hasMany (C:fast_ajaxnpm_startlearn-sequelizenode_modulessequelizelibassociationsmixin.js:13:13)

at Object. (C:fast_ajaxnpm_startlearn-sequelizemodelsindex.js:19:9)

at Module._compile (module.js:652:30)

at Object.Module._extensions..js (module.js:663:10)

at Module.load (module.js:565:32)

at tryModuleLoad (module.js:505:12)

at Function.Module._load (module.js:497:3)

at Module.require (module.js:596:17)

at require (internal/module.js:11:18)

at Object. (C:fast_ajaxnpm_startlearn-sequelizeapp.js:11:19)

at Module._compile (module.js:652:30)

at Object.Module._extensions..js (module.js:663:10)

at Module.load (module.js:565:32)

at tryModuleLoad (module.js:505:12)

at Function.Module._load (module.js:497:3)

at Module.require (module.js:596:17)

at require (internal/module.js:11:18)

at Object. (C:fast_ajaxnpm_startlearn-sequelizebinwww:7:11)

at Module._compile (module.js:652:30)

at Object.Module._extensions..js (module.js:663:10)

at Module.load (module.js:565:32)

at tryModuleLoad (module.js:505:12)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! learn-sequelize@0.0.0 start: node ./bin/www

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the learn-sequelize@0.0.0 start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:UsershyunsepkAppDataRoamingnpm-cache_logs2018-11-11T07_15_08_813Z-debug.log

===========================================================

index.js

============================================================

const path = require('path');

const Sequelize = require('sequelize');

const env = process.env.NODE_ENV || 'development'; // production

const config = require('../config/config.json')[env]

const sequelize = new Sequelize(config.database, config.username, config.password, config);

const db = {}

db.Sequelize = Sequelize;

db.sequelize = sequelize;

db.User = require('./user')(sequelize,Sequelize)

db.Comment = require('./comment')(sequelize,Sequelize)

// db.User.hasMany(db.Comment, {foreignkey: 'name'})

db.User.hasMany(db.Comment, { foreignKey: 'commenter', sourceKey:'id'});

db.Comment.belongTo(db.User, {foreignKey: 'commenter', targetKey:'id'});

module.exports = db;

====

javascript mongodb mysql nodejs

답변 1

0

제로초(조현영)

comment.js에서 return sequelize.define을 안 하셨네요.

실제 서비스에서도 cluster를 사용하나요?

1

314

2

캐싱에 관하여

0

279

3

salt를 실무에서 사용할때 항상 randomBytes로 만들어줘야 하나요?

0

347

1

게시물 올리기 오류

0

408

1

캐슁 이후 로그인창

0

266

1

kakao passport 질문있습니다.

0

493

3

global객체 공유 질문드립니다.

1

418

1

서버가 죽어버리네요

0

1047

8

포링키 문제..

0

235

2

커넥션 플래시 설치문제

0

216

2

익스프레스 제너레이터? 설치문제

0

2586

6

redis 질문입니다.

0

305

1

9장 세션을 DB에 저장시 리다이렉션 오류 발생

0

874

8

프레임워크 선택에 관하여 질문이 있습니다.

0

300

3

시퀄라이즈 질문입니다 ! !

0

588

1

리뉴얼 강의 12강 socket.io에서 req.session접근 관련 질문

0

922

6

oAuth 질문입니다.

0

356

3

GCP 질문입니다.

0

366

1

Passport 모듈 로그인 구현관련

0

720

6

카카오 로그인 관련 질문입니다!!

0

606

4

스스로 해보기 10-16 nunjuncks 질문있습니다

0

499

5

제로초님 HTTP 완벽가이드 추천해주신거 너무 잘 읽었습니다.

0

317

2

gif채팅방 nunjucks관련 질문입니다!

0

338

3

현영님 몽고db관련 질문입니다.

0

233

3