Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const map = new Map();
  2. 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'])
  3. .then(async res1 => Promise.all(res1.map((r, i) => {
  4.     if (res1[i + 1]) {
  5.         return pool.query(`SELECT * FROM get_hwtable($1, $2)`, [r.trip_id, res1[i + 1].trip_id])
  6.         .then(res => {
  7.             const { rows: hwRows } = res;
  8.             map.set([res1[i].trip_id, res1[i + 1].trip_id], hwRows);
  9.         }).catch(e => console.log('20', e))
  10.     }                                
  11. })))
  12. .catch(e => console.log('25', e))
  13. .finally(function () {
  14.     console.log(map);
  15. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement