Showing
5 changed files
with
12 additions
and
20 deletions
| ... | @@ -20,6 +20,7 @@ title TEXT NOT NULL, | ... | @@ -20,6 +20,7 @@ title TEXT NOT NULL, |
| 20 | post TEXT NOT NULL, | 20 | post TEXT NOT NULL, |
| 21 | created_at DATETIME NOT NULL DEFAULT now(), | 21 | created_at DATETIME NOT NULL DEFAULT now(), |
| 22 | status TINYINT NOT NULL, | 22 | status TINYINT NOT NULL, |
| 23 | +mbti CHAR(4) NOT NULL, | ||
| 23 | PRIMARY KEY(id), | 24 | PRIMARY KEY(id), |
| 24 | INDEX userid_idx (userid ASC), | 25 | INDEX userid_idx (userid ASC), |
| 25 | CONSTRAINT commenter FOREIGN KEY (userid) REFERENCES tunnel.users (name) | 26 | CONSTRAINT commenter FOREIGN KEY (userid) REFERENCES tunnel.users (name) | ... | ... |
| ... | @@ -10,7 +10,6 @@ module.exports = class Comment extends Sequelize.Model { | ... | @@ -10,7 +10,6 @@ module.exports = class Comment extends Sequelize.Model { |
| 10 | userid:{ | 10 | userid:{ |
| 11 | type: Sequelize.STRING(30), | 11 | type: Sequelize.STRING(30), |
| 12 | allowNull: false, | 12 | allowNull: false, |
| 13 | - unique:true, | ||
| 14 | }, | 13 | }, |
| 15 | comment:{ | 14 | comment:{ |
| 16 | type: Sequelize.TEXT, | 15 | type: Sequelize.TEXT, | ... | ... |
| ... | @@ -20,6 +20,10 @@ module.exports = class Post extends Sequelize.Model { | ... | @@ -20,6 +20,10 @@ module.exports = class Post extends Sequelize.Model { |
| 20 | allowNull: false, | 20 | allowNull: false, |
| 21 | defaultValue: Sequelize.NOW, | 21 | defaultValue: Sequelize.NOW, |
| 22 | }, | 22 | }, |
| 23 | + mbti:{ | ||
| 24 | + type: Sequelize.CHAR(4), | ||
| 25 | + allowNull: false, | ||
| 26 | + } | ||
| 23 | },{ | 27 | },{ |
| 24 | sequelize, | 28 | sequelize, |
| 25 | timestamps:false, | 29 | timestamps:false, |
| ... | @@ -35,9 +39,5 @@ module.exports = class Post extends Sequelize.Model { | ... | @@ -35,9 +39,5 @@ module.exports = class Post extends Sequelize.Model { |
| 35 | 39 | ||
| 36 | static associate(db) { | 40 | static associate(db) { |
| 37 | db.Post.belongsTo(db.User,{foreignKey: 'userid', targetKey:'name' }); | 41 | db.Post.belongsTo(db.User,{foreignKey: 'userid', targetKey:'name' }); |
| 38 | -<<<<<<< HEAD | ||
| 39 | - //db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' }); | ||
| 40 | -======= | ||
| 41 | ->>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
| 42 | } | 42 | } |
| 43 | }; | 43 | }; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,11 +12,9 @@ const {Comment}=require('../models'); | ... | @@ -12,11 +12,9 @@ const {Comment}=require('../models'); |
| 12 | router.post('/reply',auth,(req,res)=>{ | 12 | router.post('/reply',auth,(req,res)=>{ |
| 13 | 13 | ||
| 14 | Comment.findAll({ | 14 | Comment.findAll({ |
| 15 | -<<<<<<< HEAD | 15 | + |
| 16 | - where:{postid: req.params.id}, | ||
| 17 | -======= | ||
| 18 | where:{postid: req.body.id}, | 16 | where:{postid: req.body.id}, |
| 19 | ->>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | 17 | + |
| 20 | order: [['created_at', 'ASC']], | 18 | order: [['created_at', 'ASC']], |
| 21 | }) | 19 | }) |
| 22 | .then((result)=>{ | 20 | .then((result)=>{ |
| ... | @@ -40,11 +38,8 @@ router.post('/write',auth,(req,res)=>{ | ... | @@ -40,11 +38,8 @@ router.post('/write',auth,(req,res)=>{ |
| 40 | try{ | 38 | try{ |
| 41 | Comment.create({ | 39 | Comment.create({ |
| 42 | userid : req.session.name, | 40 | userid : req.session.name, |
| 43 | -<<<<<<< HEAD | ||
| 44 | - postid : req.body.id, | ||
| 45 | -======= | ||
| 46 | postid : req.body.postid, | 41 | postid : req.body.postid, |
| 47 | ->>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | 42 | + |
| 48 | comment : req.body.comment, | 43 | comment : req.body.comment, |
| 49 | }) | 44 | }) |
| 50 | console.log("게시"); | 45 | console.log("게시"); | ... | ... |
| ... | @@ -9,12 +9,8 @@ const {Post}=require('../models'); //게시물정보 db연결 | ... | @@ -9,12 +9,8 @@ const {Post}=require('../models'); //게시물정보 db연결 |
| 9 | //현재 로그인된 사용자의 게시물 배열 응답 | 9 | //현재 로그인된 사용자의 게시물 배열 응답 |
| 10 | router.get('/',auth,(req,res)=>{ | 10 | router.get('/',auth,(req,res)=>{ |
| 11 | Post.findAll({ | 11 | Post.findAll({ |
| 12 | - // where:{userid: req.session.name}, | 12 | + where:{mbti: req.session.personality}, |
| 13 | -<<<<<<< HEAD | 13 | + order: [['created_at', 'DESC']], |
| 14 | - // order: [['created_at', 'DESC']], | ||
| 15 | -======= | ||
| 16 | - order: [['created_at', 'DESC']], | ||
| 17 | ->>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
| 18 | }) | 14 | }) |
| 19 | .then((result)=>{ | 15 | .then((result)=>{ |
| 20 | //console.log(result); | 16 | //console.log(result); |
| ... | @@ -40,7 +36,8 @@ router.post('/',auth,(req,res)=>{ | ... | @@ -40,7 +36,8 @@ router.post('/',auth,(req,res)=>{ |
| 40 | userid : req.session.name, | 36 | userid : req.session.name, |
| 41 | title : req.body.title, | 37 | title : req.body.title, |
| 42 | post: req.body.content, | 38 | post: req.body.content, |
| 43 | - status: false | 39 | + status: false, |
| 40 | + mbti : req.session.personality | ||
| 44 | }) | 41 | }) |
| 45 | console.log("게시"); | 42 | console.log("게시"); |
| 46 | res.sendStatus(200); | 43 | res.sendStatus(200); | ... | ... |
-
Please register or login to post a comment