const { Client } = require('pg');
const config = {
host: "127.0.0.1",
database: "postgres",
user: "postgres",
password: "postgres",
port: 5432,
}
const pg = require("pg");
const pool = new pg.Pool({
host: "127.0.0.1",
database: "postgres",
user: "postgres",
password: "postgres",
port: 5432,
max: 20,
idleTimeoutMillis: 3000
})
function qurey_files(req, res) {
var strSql =
"select name, path, suffix, status, \
to_char(upload_date_time,'yyyy-mm-dd_HH24:MI:ss') as time \
from public.\"Test\" \
ORDER BY key ASC";
let client = new Client(config);
client.connect();
client.query(strSql, (err, result) => {
if (err) {
res.status(404).send(err.message);
console.log(err);
}
else {
res.send(result.rows);
}
client.end();
})
}
function qurey_files_pool(req, res) {
var strSql =
"select name, path, suffix, status, \
to_char(upload_date_time,'yyyy-mm-dd_HH24:MI:ss') as time \
from public.\"Test\" \
ORDER BY key ASC";
pool.connect((err, client, done)=>{
client.query(strSql, (err, result)=>{
done();
res.send(result.rows);
})
})
}
module.exports = {
qurey_files,
qurey_files_pool
}
const db = require('./server/pgsql')
db.qurey_files_pool(req, res)