Commit 4c8a6fff authored by Peter Lundin's avatar Peter Lundin
Browse files

Delete relation.js

parent ca2c62c6
var express = require('express');
var router = express.Router();
const jQuery = require('jquery');
const path = require('path');
const config = require('./config');
const pg = require('pg');
const winston = require('winston');
const connectionString = process.env.DATABASE_URL || config.storageConfig;
router.post('/types', (req, res, next) => {
var pool = new pg.Pool({
connectionString: connectionString,
});
// Get a Postgres client from the connection pool
pool.connect(function(err, client, done){
// Handle connection errors
if(err) {
done();
return res.status(500).json({success: false , data: err});
}
// SQL Query > Select Data
var sql = "select * from cmdb.relation_type order by display_name;";
var parameter = [];
client.query(sql, parameter, function(err, result){
done();
if (err){
return res.json(JSON.parse('{"Result":"ERROR", "Message":"relation_type"}'));
}
else {
var response = '{"Result":"OK", "Records":';
response+= JSON.stringify(result.rows);
response+= ',"TotalRecordCount":' + result.rowCount + '}';
return res.json(JSON.parse(response));
}
});
});
});
module.exports = router;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment