-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_select.js
41 lines (36 loc) · 982 Bytes
/
db_select.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
var mysql = require('mysql');
var db = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "blogdb"
});
module.exports = {
getTopics: (req, res, next)=>{
db.connect();
console.log("hola");
db.query("SELECT * FROM post ORDER BY idpost Desc;", (err, result, fields)=>{
if(err) throw err;
return res.render('index', {entradas:result});
});
return
}
}
// getUSer: function(req, res, next){
// // var blogs;
// var mysql = require('mysql');
// var db = mysql.createConnection({
// host: "localhost",
// user: "root",
// password: "",
// database: "blogdb"
// });
// db.connect();
// db.query("SELECT idusers FROM blogdb.users Where user_name='asd';", function (err, result, fields) {
// if(err) throw err;
// // console.log(result);
// db.end();
// return res.render('index', {entradas:result});
// });
// return
// }