const { Client } = require('pg'); (async () => { const c = new Client({ connectionString: 'postgres://edr_e2e:edr_e2e@localhost:5533/edr_freight_e2e' }); await c.connect(); const r = await c.query(` SELECT ct.reference AS contract, b.reference AS bk, b.status, COALESCE(b.payment_status,'-') AS pay, (SELECT count(*) FROM freight.wagon_booking_allocations a WHERE a.booking_id=b.id AND a.deleted_at IS NULL) AS wagons FROM freight.bookings b JOIN freight.contracts ct ON ct.id=b.contract_id WHERE ct.reference LIKE 'CTR-IMP-%' AND b.deleted_at IS NULL AND b.created_at > now() - interval '30 minutes' ORDER BY b.created_at DESC LIMIT 15`); console.log(JSON.stringify(r.rows)); await c.end(); })().catch(e => { console.log(JSON.stringify({error: e.message})); });