Skip to content

Commit

Permalink
#43 myboard list query 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
AYoungSn committed Dec 19, 2021
1 parent f787b10 commit 30afa05
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions routes/myboardRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ router.get('/', function(request, response) {
if (request.user === undefined) {
response.redirect('/');
}
db.query(`SELECT post.id, post.title, post.createdate, count(*) 'count'
FROM (SELECT * FROM post WHERE post.userId=${request.user.id}) post, liked
WHERE post.id = liked.postId group by post.id`, function(err, result) {
db.query(`SELECT post.id, post.title, post.createdate, count(liked.id) 'count'
FROM (SELECT * FROM post WHERE post.userId=${request.user.id}) post left join liked
on post.id = liked.postId group by post.id`, function(err, result) {
if (err) throw err;
console.log(result)
var list ='';
console.log(result[0].createdate)
for (var i = 0;i < result.length; i++) {
list += `
<a href='/board/view?id=${result[i].id}'>
<div class="content">
<div class="content">
<a href='/board/view?id=${result[i].id}'>
<div class="subject">
<p>${result[i].title}</p>
<div class="info"><span>${request.user.nickname}</span> | <span>${result[i].createdate}</span></div>
</div>
</a>
<div class="like">
<button type="button" class="likebtn" id="img_btn"><img src="/public/img/heart_outline.png"></button>
<div class="cnt">${result[i].count}</div>
</div>
</div>
</a>
</div>
`
}
const body = boardlist.HOME(list, request.user);
Expand Down

0 comments on commit 30afa05

Please sign in to comment.