mytoons2.js
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var express = require('express');
var async = require('async');
var router = express.Router();
function getMyToons2(id,cb){
//id 값을 가진 user가 저장한 웹툰들 가져오기
var sqlquery = "SELECT t.name, t.thum_link, t.webtoon_link, t.year, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;";
var mylist2 = new Array();
connection.query(sqlquery,id,function(err,rows,result){
if(!err){
mylist2=rows;
cb(mylist2);
console.log(mylist2);
}else{
console.log("내 웹툰 리스트 가져오는데 실패했습니다!");
//throw err;
}
});
}
/* GET home page. */
router.get('/', function(req, res, next) {
if(!req.isAuthenticated()){
res.redirect('/');
}else{
async.series(
[
function(callback){
getMyToons2(req.user.user_id, function (mytoon_list2) {
callback(null,mytoon_list2);
});
}
],
function(err, results){
res.render('mytoons2', {
mytoons2: results[0]
});
}
);
}
});
module.exports = router;