고병후

temp

......@@ -20,6 +20,7 @@ title TEXT NOT NULL,
post TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT now(),
status TINYINT NOT NULL,
mbti CHAR(4) NOT NULL,
PRIMARY KEY(id),
INDEX userid_idx (userid ASC),
CONSTRAINT commenter FOREIGN KEY (userid) REFERENCES tunnel.users (name)
......
......@@ -10,7 +10,6 @@ module.exports = class Comment extends Sequelize.Model {
userid:{
type: Sequelize.STRING(30),
allowNull: false,
unique:true,
},
comment:{
type: Sequelize.TEXT,
......
......@@ -20,6 +20,10 @@ module.exports = class Post extends Sequelize.Model {
allowNull: false,
defaultValue: Sequelize.NOW,
},
mbti:{
type: Sequelize.CHAR(4),
allowNull: false,
}
},{
sequelize,
timestamps:false,
......@@ -35,9 +39,5 @@ module.exports = class Post extends Sequelize.Model {
static associate(db) {
db.Post.belongsTo(db.User,{foreignKey: 'userid', targetKey:'name' });
<<<<<<< HEAD
//db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' });
=======
>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5
}
};
\ No newline at end of file
......
......@@ -12,11 +12,9 @@ const {Comment}=require('../models');
router.post('/reply',auth,(req,res)=>{
Comment.findAll({
<<<<<<< HEAD
where:{postid: req.params.id},
=======
where:{postid: req.body.id},
>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5
order: [['created_at', 'ASC']],
})
.then((result)=>{
......@@ -40,11 +38,8 @@ router.post('/write',auth,(req,res)=>{
try{
Comment.create({
userid : req.session.name,
<<<<<<< HEAD
postid : req.body.id,
=======
postid : req.body.postid,
>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5
comment : req.body.comment,
})
console.log("게시");
......
......@@ -9,12 +9,8 @@ const {Post}=require('../models'); //게시물정보 db연결
//현재 로그인된 사용자의 게시물 배열 응답
router.get('/',auth,(req,res)=>{
Post.findAll({
// where:{userid: req.session.name},
<<<<<<< HEAD
// order: [['created_at', 'DESC']],
=======
order: [['created_at', 'DESC']],
>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5
where:{mbti: req.session.personality},
order: [['created_at', 'DESC']],
})
.then((result)=>{
//console.log(result);
......@@ -40,7 +36,8 @@ router.post('/',auth,(req,res)=>{
userid : req.session.name,
title : req.body.title,
post: req.body.content,
status: false
status: false,
mbti : req.session.personality
})
console.log("게시");
res.sendStatus(200);
......