2015-09-23 16:32:17 -04:00
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
|
|
|
|
/* GET home page. */
|
|
|
|
router.get('/:id', function(req, res, next) {
|
2015-09-29 17:04:17 -04:00
|
|
|
var config = res.locals.config;
|
2015-09-23 16:32:17 -04:00
|
|
|
var db = config.init_db();
|
|
|
|
|
2015-09-23 18:41:47 -04:00
|
|
|
var shows = [];
|
2015-09-23 16:32:17 -04:00
|
|
|
|
2017-09-27 09:09:25 -04:00
|
|
|
//we do all the basic operations following
|
2015-09-23 16:32:17 -04:00
|
|
|
db.serialize(function() {
|
|
|
|
|
2015-09-23 18:41:47 -04:00
|
|
|
db.each("SELECT id, title, year"
|
|
|
|
+ " FROM metadata_items "
|
|
|
|
+ " WHERE parent_id IS NULL AND library_section_id = ? "
|
2015-09-23 16:32:17 -04:00
|
|
|
,req.params.id, function(err, row) {
|
2015-09-23 18:41:47 -04:00
|
|
|
shows.push(row);
|
2015-09-23 16:32:17 -04:00
|
|
|
},
|
2017-09-27 09:09:25 -04:00
|
|
|
//after all the operations of the database
|
2015-09-23 17:17:40 -04:00
|
|
|
function(){
|
2015-09-23 16:32:17 -04:00
|
|
|
console.log(shows);
|
2017-09-27 08:11:26 -04:00
|
|
|
res.render('show_list', { title: 'List of series',shows: shows, channel_id: req.params.id });
|
2015-09-23 16:32:17 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
db.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|