-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitems.js
51 lines (43 loc) · 838 Bytes
/
items.js
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
45
46
47
48
49
50
51
/**
* Created by PC on 4/8/2018.
*/
var express = require('express');
var router = express.Router();
var items;
/*
router.get('/', function(req, res, next) {
res.render('items/all_matiriels', { title: 'Express' });
});
*/
//create my sql
const mysql=require('mysql');
//create connection
var db = mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'stock'
});
//connect
db.connect(function(err){
if(err){
throw err;
}
console.log('mysql connected.');
});
db.query("SELECT * FROM batch",
function (err, res) {
if(err) throw err;
if(res.length>0){
items = res;
}
else {
items=null;
}
});
router.get('/items',function (req,res,next) {
res.render('items/batchs',{
items:items
});
});
module.exports = router;