pg-rest-api/src/service/pt-by-ifleet.js

22 lines
813 B
JavaScript

const debug=require('debug')('debug');
debug('pt-by-ifleet start...');
const db = require('./db');
async function get(tripshortname = 0) {
//debug('tripshortname: '+tripshortname);
const QUERY=`SELECT trip_id,trip_short_name,trip_headsign,routes.route_id,routes.route_short_name,routes.route_type,agency.agency_id,agency.agency_name,agency.agency_url FROM agency,routes,trips WHERE trip_short_name ='${tripshortname}' AND trips.route_id = routes.route_id AND routes.agency_id = agency.agency_id;`;
//debug('QUERY: '+QUERY);
const resp = await db.query(QUERY);
//debug('resp: '+resp);
//debug('resp: '+JSON.stringify(resp[0]));
/*TODO Handle respnse array where records differ in service_id.*/
return resp[0];
}
module.exports = {
get
}
debug('pt-by-ifleet done.');