inflearn logo
강의

Course

Instructor

Creating Nodebird SNS with Vue

4-5. Sequelize Model and User Registration

안녕하세요 선생님!

361

yunhwan19037701

8 asked

0

response 로그를 찍어보면 email이 잘 들어있는데 notNull Violation: User.email cannot be null 에러가 뜨는 이유가 궁금합니다 선생님!

ssr vuex nodejs aws mysql vuejs

Answer 5

0

yunhwan19037701

라우터 부분 코드도 추가했습니다!

0

yunhwan19037701

const express = require('express');
const db = require('./models');
const cors = require('cors');

const app = express();

db.sequelize.sync();

app.use(express.json());
app.use(cors({
origin: 'http://localhost:3000',
credentials: true,
}));

app.get('/', (req, res) => {
res.send('hello backend')
})

app.post('/user', async (req, res, next) => {
try {
console.log(req.body)
const newUser = await db.User.create({
where: {
email : req.body.email,
password : req.body.password,
nickname : req.body.nickname,
}
});
res.status(201).json(newUser);
} catch (err) {
console.log(err);
next(err);
}
})

app.listen(3085, () => {
console.log('backend server on ${3085} port')
})




0

yunhwan19037701

워크벤치에서도 테이블이 보이지 않습니다!

0

zerocho

테이블이 안 보이는 것은 워크벤치 커넥션을 잘못 맺으신 것 같기도 하고요. 일단 SCHEMAS 아이콘 오른쪽에 새로고침 아이콘 눌러보세요.

0

yunhwan19037701

네 선생님

0

yunhwan19037701

안녕하세요 선생님 violation error 는 해결을 했는데요 ㅠ! 

이렇게 body는 잘 들어간 것을 확인했으나 

mysql 에서는 null로 들어가있네요 원인을 알 수 있을까요~? 

스키마 정의하는 부분 코드입니다. 

module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('User', {
email: {
type: DataTypes.STRING(40), // 40자 이내
unique: false, // 중복금지
},
nickname: {
type: DataTypes.STRING(20),
unique: false, // 중복금지
},
password: {
type: DataTypes.STRING(100),
unique: false, // 중복금지
},
}, {
charset: 'utf8',
collate: 'utf8_general_ci', // 한글 저장돼요
});
User.associate = (db) => {
// db.User.hasMany(db.Post);
// db.User.hasMany(db.Comment);
};
return User;
};

0

zerocho

서버 라우터 코드 보여주세요. email 넣을 때 오타 있는 것 같습니다.

npm run dev 할 때 에러가 발생합니다.

0

143

1

해당 강의는 리뉴얼 예정은 따로 없나요?

0

327

1

강의는 언제까지 업데이트 된 내용인가요?

0

328

2

실습 환경 문의(Node 버전)

0

364

1

로그인 새로고침시 풀림

0

290

1

안녕하세요! 로그인 유지 질문 드립니다!

0

402

1

웹 서버 관련해서 질문드립니다.

0

440

1

버전때매 질문 드립니다!!

0

312

1

이 강의는 vue3는 아닌가요??

0

371

1

vsCode에 관한 질문입니다

0

487

1

v.trim()이 타입에러가 뜹니다...

0

342

1

express.static('uploads')

0

342

2

STRING이 인식이 안되는데 이유알수있을까요?

0

445

2

<v-lsit-item-title> 에러

0

408

2

vue cli 를 실무에서도 사용하지 않으시나요?

0

318

1

선생님 처음 환경 셋팅 관련 문의드립니다.

0

384

1

nuxtServerInit 무한 로딩

0

972

3

Nginx Cookie 설정

0

720

2

상태가 204번인경우에는 어떻게 처리를 해야하나요?

0

291

1

선생님 nuxt 관련질문드립니다.

0

348

1

인덱스 비교로 삭제해도 될까요?

0

382

1

질문 드립니다!

0

330

2

안녕하세요

0

225

1

궁금한점이있습니다

0

235

1