Commit 16c040410327fd5798e86738cbab694ecc2cc711
1 parent
77660f74
Exists in
master
Adiciona endpoint /countVideo
Showing
2 changed files
with
22 additions
and
3 deletions
Show diff stats
.gitignore
routes/index.js
... | ... | @@ -24,6 +24,21 @@ router.get('/', function(req, res, next) { |
24 | 24 | res.render('index', { title: 'Express' }); |
25 | 25 | }); |
26 | 26 | |
27 | +router.get('/countVideo', function(req, res, next) { | |
28 | + var results = []; | |
29 | + db.query('SELECT COUNT(*) FROM sinal') | |
30 | + .then(function (result) { | |
31 | + res.send(203, [parseInt(result[0].count)]); | |
32 | + }) | |
33 | + .catch(function (error) { | |
34 | + res.send(203, ["Error: Invalid Query"]); | |
35 | + console.log(error); | |
36 | + }) | |
37 | + .finally(function() { | |
38 | + pgp.end(); | |
39 | + }); | |
40 | +}); | |
41 | + | |
27 | 42 | router.get('/listall', function(req, res, next) { |
28 | 43 | |
29 | 44 | var results = []; | ... | ... |