Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const map = new Map();
- pool.query(`SELECT * FROM trips WHERE destination = $1 AND begin_time >= $2 AND begin_time < $3 ORDER BY begin_time`, ['BROWNSVILLE ROCKAWAY AV', '2018-07-18 00:00-04:00', '2018-07-19 00:00-04:00'])
- .then(async res1 => Promise.all(res1.map((r, i) => {
- if (res1[i + 1]) {
- return pool.query(`SELECT * FROM get_hwtable($1, $2)`, [r.trip_id, res1[i + 1].trip_id])
- .then(res => {
- const { rows: hwRows } = res;
- map.set([res1[i].trip_id, res1[i + 1].trip_id], hwRows);
- }).catch(e => console.log('20', e))
- }
- })))
- .catch(e => console.log('25', e))
- .finally(function () {
- console.log(map);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement